hi, most simple example of OmniThread lib looks like
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
procedure TfrmDemoParallelAsync.btnAsyncClick(Sender: TObject); begin btnAsync.Enabled := false; Parallel.Async( procedure begin // executed in background thread Caption := 'Work...'; Sleep(500); MessageBeep($FFFFFFFF); end, Parallel.TaskConfig.OnTerminated( procedure(const task: IOmniTaskControl) begin // executed in main thread btnAsync.Enabled := true; Caption := 'Ready'; end)); end; |
GUI is responsive during executing the code…