in Delphi Threading ::
Just a few days after I wrote the AsyncCalls Unit By Andreas Hausladen - Let's Use (and Extend) It! article Andreas did release a new 2.99 version of AsyncCalls. The IAsyncCall interface now includes three more methods:
- The CancelInvocation method stopps the AsyncCall from being invoked. If the AsyncCall is already processed, a call to CancelInvocation has no effect and the Canceled function will return False as the AsyncCall wasn't canceled.
- The Canceled method returns True if the AsyncCall was canceled by CancelInvocation.
- The Forget method unlinks the IAsyncCall interface from the internal AsyncCall. This means that if the last reference to the IAsyncCall interface is gone, the asynchronous call will be still executed. The interface's methods will throw an exception if called after calling Forget. The async function must not call into the main thread because it could be executed after the TThread.Synchronize/Queue mechanism was shut down by the RTL what can cause a dead lock.
Note, though, that you can still benefit from my AsyncCallsHelper if you need to wait for all async calls to finish with "asyncHelper.WaitAll"; or if you need to cancel the invocation for all not finished (or already cancelled) tasks using "asyncHelper.CancelAll".
Related:
Comments
No comments yet. Leave a Comment
