kbmMW contains a pretty powerful job scheduler which in next release of kbmMW becomes even more powerful.
It can execute things in a regular interval under various conditions.
But it can also be used for running code asynchronously without having manually to create threaded code.
Scheduler.RunNow( procedure begin somelongrunningmethod; end);
The procedure will be executed immediately in a different thread, without blocking the executing of the current thread.
But sometimes you want the result of the asynchronous executing to be output to the GUI. And kbmMW’s scheduler now contains easy access to doing that.
var res:sometype; begin Scheduler.Run( procedure begin res:=somelongrunningfunction; end) .SynchronizedAfterRun( procedure begin Memo1.Lines.Add(res); end) .Activate(true);
In this case, somelongrunningfunction is executed in a seperate thread, and its return value is placed in res. When the result is back, the code in SynchronizedAfterRun is executed, this time synchronized with the main thread, which makes it GUI safe.
Super easy way to execute async with support for updating GUI afterwards.
19,246 total views, 4 views today