Allows elegant implementation of event driven code and other similar idioms. Node.js makes heavy use of such concepts; a more relevant example would be OmniThreadLibrary (Delphi-only):
procedure TfrmDemoParallelAsync.btnAsyncClick(Sender: TObject);
begin
btnAsync.Enabled := false;
Parallel.Async(
procedure
begin
// executed in background thread
Sleep(500);
MessageBeep($FFFFFFFF);
end,
procedure
begin
// executed in main thread
btnAsync.Enabled := true;
end
);
end;
Allows elegant implementation of event driven code and other similar idioms. Node.js makes heavy use of such concepts; a more relevant example would be OmniThreadLibrary (Delphi-only):