The WCFFacility provides some extension methods that conform to the old async pattern. These can easily be converted to Tasks.
Try these extension methods:
public static class ClientExtensions
{
public static async Task<TResult> CallAsync<TProxy, TResult>(this TProxy proxy, Func<TProxy, TResult> method)
{
return await Task.Factory.FromAsync(proxy.BeginWcfCall(method), ar => proxy.EndWcfCall<TResult>(ar));
}
public static async Task CallAsync<TProxy>(this TProxy proxy, Action<TProxy> method)
{
await Task.Factory.FromAsync(proxy.BeginWcfCall(method), ar => proxy.EndWcfCall(ar));
}
}
In an async method they can be called like this:
// Func<T>
var result = await client.CallAsync(p => p.SayThisNumber(42));
// Action
await client.CallAsync(p => p.DoSomething());