Вверх ↑
Ответов: 1925
Рейтинг: 172
#1: 2020-09-06 21:07:17 ЛС | профиль | цитата
Как-то так:

Add(InlineCode,9836184,343,322)
{
WorkPoints=#1:a|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|21:uses kol,Share,Debug;|0:|4:type|28: THiAsmClass = class(TDebug)|10: private|16: th1:PThread;|16: th2:PThread;|47: function Execute1(Sender:PThread): Integer;|47: function Execute2(Sender:PThread): Integer;|9: public|17: //:THI_Event;|0:|42: procedure a(var dt:TData; index:word);|0:|5: end;|0:|14:implementation|0:|24:procedure THiAsmClass.a;|5:begin|79: //Это значит, что при каждом новом вызове метода потоки будут перезапускаться:|32: if Assigned(th1) then th1.Free;|32: if Assigned(th2) then th2.Free;|62: //Если епрезапускать не нужно - вместо th1/2.Free ставим exit|0:|62: th1 := {$ifdef F_P}NewThreadforFPC{$else}NewThread{$endif};|29: th1.OnExecute := Execute1;|14: th1.Resume;|0:|62: th2 := {$ifdef F_P}NewThreadforFPC{$else}NewThread{$endif};|29: th2.OnExecute := Execute2;|14: th2.Resume;|4:end;|0:|31:procedure THiAsmClass.Execute1;|5:begin|15: //первый поток|17: //_hi_OnEvent();|4:end;|0:|31:procedure THiAsmClass.Execute2;|5:begin|15: //второй поток|17: //_hi_OnEvent();|4:end;|0:|4:end.|
}
Уже внутри execute можно repeat поставить, как в компоненте.
А можно сделать array of PThread
карма: 9
0