AcceptAsync和BeginAccept的区别

原文链接

http://stackoverflow.com/questions/3081079/difference-between-async-and-begin-net-asynchronous-apis


Note that most *Async methods (with corresponding *Completed events) are using the Event-Based Asynchronous Pattern. The older (but still perfectly valid) Begin* and End* is a pattern called the Asynchronous Programming

大多数的*Async方法(相当于*Completed 事件)使用了“基于事件的异步模式”,Begin* and End*使用的是“异步编程模型”

Model. The Socket class is an exception to this rule; its *Async methods do not have any corresponding events; it's essentially just APM done in a way to avoid excessive memory allocations.

对此规则,socket有一个例外:Async 并没有任何的相应的事件,为了避免过多的内存分配,它本质上还是使用的"异步编程模型"

 

 

The biggest difference between APM and EBAP is the thread used for completion notification. APM will call back on a thread pool thread (unless the request completes synchronously). EBAP will use a cross-framework strategy to

二者最大的不同在于,为了完成通知而使用的线程。异步编程模型begin*回调一个线程池(除非请求被同步的完成了),*Async使用一个 cross-framework策略来回调ui线程(如果此操作是从一个ui线程开始的)

call back on a UI thread (if the operation was started from a UI thread).

 

However, both APM and EBAP are being replaced with a much more flexible approach based on the Task Parallel Library. Since the TPL can wrap APMs easily, older classes will likely not be updated directly; extension methods are used to provide Task equivalents for the old APM methods.

Update 2012-07-14: I was wrong when I stated "older classes will likely not be updated directly". For performance reasons, the BCL/TPL teams decided to review each BCL type and add TAP methods directly instead of using extension methods. These changes will be in .NET 4.5.

你可能感兴趣的:(async)