TccScriptThreads Beispiel

Übersicht

Einfaches Beispiel, welches die grundlegende Funktionsweise der TccScriptThreads Klasse demonstriert.

Script

Threads := TccScriptThreads.Create;
try
  ShowMessage(Threads.NumberOfProcessors);

  Threads.Add('function ccThread : Variant; begin ShowMessage(Test1); Result := true; end;',tpLowest);
  Threads.Add('function ccThread : Variant; begin sleep(5000); ShowMessage(Test2); Result := true; end;',tpNormal,'Tst');
  Threads.Add('function ccThread : Variant; begin ShowMessage(Test3); Test3 := 123; Result := 456; end;');

  Threads.AddParameter(0,'Test1','Hello World One!');
  Threads.AddParameter(1,'Test2','Hello World Two!');
  Threads.AddParameter(2,'Test3','Hello World Three!');

  Threads.Start;

  ShowMessage(Threads.GetParameter(2,'Test3',''));
  ShowMessage(Threads.GetResult(2));
finally
  Threads.Free;
end;

Thread-Script

function ccThread : Variant; 
begin 
  ShowMessage(Test1); 
  Result := true; 
end;