Click here to Skip to main content
Click here to Skip to main content
Go to top

Begin/End asynchronous methods vs the new Async methods

, 6 Sep 2011
Rate this:
Please Sign up or sign in to vote.
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 work. 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)

Share

About the Author

jgauffin
Founder Gauffin Interactive AB
Sweden Sweden
Founder of OneTrueError, a .NET service which captures, analyzes and provide possible solutions for exceptions.
 
blog | twitter
Follow on   Twitter   LinkedIn

Comments and Discussions

 
GeneralMy vote of 3 PinmemberMarcio_Coelho13-Sep-11 7:18 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140905.1 | Last Updated 6 Sep 2011
Article Copyright 2011 by jgauffin
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid