The Asynchronous Programming Model (APM) is one of the oldest patterns introduced by Microsoft in .NET 1.0 back in 2001 for asynchronous programming handling.
The pattern is easy. To start a deferred job, you simply start such a job by using a
Delegate (remote method invoker) and then get an object back of type IAsyncResult
to know the status of such a remote operation. Here an asynchronous programmed application to compute file hashes. The application will add a ".
" to the Starting data computation
initial message to acknowledge to the user that the application is still processing. The following examples use the blocking approach:
static void Main(string[] args) { //a container for data var complexData = new byte[1024]; //a delegate object that gives us the ability to trigger the pointed method in async way var dataDelegate = new Action<byte[]>(ComputeComplexData); Console.Write("Starting data computation..."); //start...