If I call a WCF service method I would do something like this:
proxy.DoSomethingAsync();
proxy.DoSomethingAsyncCompleted += OnDoSomethingAsyncCompleted;
It is quite common to have asynchronous clients calling a synchronous service.
The following client and service contracts match (a bit magic used behind the scenes):
[ServiceContract( Namespace="X", Name="TheContract" )]
public interface IClientContractAsynchronous
{
[OperationContract]
Task SendReceiveAsync( TRequest req );
}
[ServiceContract( Namespace="X", Name="TheContract" )]
public interface IServiceContractSynchronous
{
[OperationContract]
TResponse SendReceive( TRequest req );
}
The client interface is directly awaitable:
var response = await client.Channel.SendReceiveAsync( request );
It is not possible to use out or ref parameters in the operaton contract. All response data must be passed in the return value. This actually was a breaking change for me.
I use this interface in AsyncWcfLib, it supports a Actor based programming model.