A new asynchronous model was introduced in .NET 3.5sp1 where all methods end with ‘
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
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.