WCFFacility provides some extension methods that match the old async pattern. They 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 the asynchronous 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());
source share