This is a mirror of official site: http://jasper-net.blogspot.com/

Implementing the IAsyncResult interface and calling functions asynchronously

| Wednesday, March 24, 2010
One of the interesting features in .NET framework programming is the ability to easily use asynchronous programming and multi threading. .NET offers a wide variety of methods for asynchronous programming and for working with threads, but this was made very much easier with .NET 2.0. Building multithreaded applications in .NET 1.0 and .NET 1.1 has been made very convenient with classes like Thread and ThreadStart delegates. The ThreadPool class is useful in managing threads in multithreaded applications.

In a quick glance, we can see that the addition of the BackgroundWorker class has added to the Windows application tool set.

We can do an asynchronous callback for ASP.NET pages by adding the attribute:

<%@ Page Async="true" ... %>

This has made it very easy for users (even beginners) to use these facilities.

I will not talk about how to use multithreading in .NET, this is out of the scope of this article and the internet is full of such articles.

I will be talking about how to make your methods callable asynchronously by creating begin/end pair stems, in a similar way that the WSDL.exe tool generates the contract files for a Web Service. You will need this when you make a service or something like that and you want others to use it in an asynchronous way, to make it easy for them to implement it and enhance the performance without the need for them to create more threads and manage them etc.

Background

I got really interested in the subject when I was developing a Smart Client application from scratch. In the beginning, I made a Web Service and coded all its functionality. Then, I built up a Windows client application which consumed the functionality of the service, and in order to enhance performance, I consumed the service in its Begin/End pair of methods, asynchronously.

Read more: Codeproject

Posted via email from jasper22's posterous

0 comments: