Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Begin/End Asynchronous Methods vs the New Async Methods

3.00/5 (1 vote)
6 Sep 2011LGPL31 min read 17.3K  
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)