|
Normal applications execute synchronously. In other words, one process completes
before the next process begins. Here is some example pseudo-code.
Run process one
Run process two
Display 'All Done' message
Multi-threaded applications execute asynchronously. In other words,
several processes can execute at the same time. In the above pseudo-code,
the 'All Done' message would display when process one and two have only started,
if process one and two were asynchronous processes.
So, how do you know when to display the 'All Done' message in a multi-threaded
program? The answer is event notifications. Async provides a Finished
event that fires when a threaded process completes. The Finished event includes
a key that identifies which threaded process is complete.
Additionally you can add custom notifications using the Report
event. With the report event you can communicate any information
you want, from your DLL to your application.
Asynchronous programming is not just for multiple processes! Using event
notification and asynchronous processing has the additional benefit of
keeping an application from being blocked until a process completes.
This makes it possible to cancel a threaded process prematurely or to
access other methods and properties while the threaded process is running.
|