Click here to Skip to main content
15,893,588 members
Articles / Programming Languages / C#

Begin/End Asynchronous Methods vs the New Async Methods

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
6 Sep 2011LGPL31 min read 17K   3   1
An article helping you choose which asynchronous model you should use in your .NET project.

A new asynchronous model was introduced in .NET 3.5sp1 where all methods end with ‘Async’ like Socket.RecieveAsync. I will not give you any code samples, there are several articles out there which show how the new model works. Instead, I’m going to try to help you understand the differences and to select which model you should use for your project.

The benefit with the new model is that it’s a lot more similar to the I/O Completion Ports threading model which exists in Windows (and is used internally for all asynchronous operations in .NET). The idea is that the IO model should create as few objects as possible per operation, compared to the old model where one IAsyncResult object is created per operation.

I haven’t looked at the code (using reflector) for the old model versus the new one, but I bet that the code for the new model is a lot more efficient than the old one since it’s more similar to IOCP.

Which Method Should You Choose Then?

Choose the one that you are most comfortable with (which probably is Begin/End since it’s the model that has existed since day one). It’s more likely that you loose performance instead of gaining if you pick a model that you do not fully understand.

As always: Never optimize something unless it has been proven to be a problem.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Founder 1TCompany AB
Sweden Sweden

Comments and Discussions

 
GeneralMy vote of 3 Pin
Marcio_Coelho13-Sep-11 7:18
Marcio_Coelho13-Sep-11 7:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.