This is a mirror of official site: http://jasper-net.blogspot.com/

Simplified Asynchronous Programming Model in WCF with async/await

| Sunday, November 14, 2010
Managing multiple asynchronous operations in WCF is currently very complex regardless of whether you use the existing event or Begin/End asynchronous patterns. In fact, both internal and external customers frequently ask about how to implement simple coordination of WCF operations, and even though sending multiple requests to a WCF backend is a core scenario, WCF does not provide a satisfactory solution. The amount of code needed to facilitate even simple coordination tasks is large and prone to bugs, handling errors and timeouts. Yet there are some very common communication-oriented scenarios that require managing multiple outstanding asynchronous operations:

Execute multiple async operations in parallel and continue when they are all done, either successfully, failed, or timed out.
Execute sequence of asynchronous operations, stopping if one of the operations fails or times out.
Nest multiple asynchronous operations.
Combine asynchronous operations with timers for easy polling at regular intervals.
However, regardless of the current complexity, WCF developers have to use asynchronous requests to write robust implementations, and doing that today is a difficult challenge.

During PDC’10, the C# and VB languages teams released the Visual Studio Async CTP, which aims at providing a new simplified model for doing asynchronous programming in both languages. In WCF, we have decided to adopt this model because we believe it removes the barrier to writing WCF robust asynchronous application, has the least possible learning curve from the existing CLR APM pattern, and provides a simple and consistent model for coordinating, submitting and managing multiple asynchronous WCF operations.

WCF vNext will adopt the Async model in both the client and the server side, and provide new Task-based overloads for some of the most used asynchronous APIs:

Server Side
  WCF service developers will be able to define asynchronous operation contracts that return Task/Task<T>:

[ServiceContract]
public interface IServiceContract
{
   [OperationContract]
   Task<string> Hello(string name);
}

As you may notice, there is no need to switch OperationContract.AsyncPattern to true anymore (yeah!), or define Begin/End methods in your service contract.

Read more: The .NET Endpoint

Posted via email from .NET Info

1 comments:

Anonymous said...

I read this paragraph completely concerning the comparison of
hottest and previous technologies, it's awesome article.

Here is my site: registry cleaner review
My web page - best registry cleaner