Code of the day:

Code of the day:
procedure TForm1.Button1Click(Sender: TObject);
var
aTask: ITask;
begin
aTask := TTask.Create (procedure ()
begin
sleep (3000); // 3 seconds
ShowMessage ('Hello');
end);
aTask.Start;
end;

From http://docwiki.embarcadero.com/RADStudio/Berlin/en/Using_TTask_from_the_Parallel_Programming_Library
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Using_TTask_from_the_Parallel_Programming_Library

Comments

  1. Ok now I remember that calling Sleep(0) it's fine because you are telling the OS that your thread relinquish it's time slice and it should schedule for another thread that might be waiting

    ReplyDelete

Post a Comment