I assume you are using VS2012.
First, if your goal is .NET 4.0, then install (via NuGet) the Async Targeting package. If your goal is .NET 4.5, you don’t have to do anything special.
Then recreate your client proxy. Existing Begin / End / Async endpoints will be replaced with one Task<Company> GetCompanyInfoAsync(Guid) .
Now you can use it as follows:
public static Task<Company> LoadCompanyInfoAsync(Guid session) { var client = new QualerServiceClient("QualerService"); return client.GetCompanyInfoAsync(session); } public async void ButtonClickOrWhatever(...) { var company = await LoadCompanyInfoAsync(mySession);
The old pair of Begin / End methods used the asynchronous programming model (APM). The old Async / event pair used an event -based asynchronous programming (EAP) model. The new Async method uses a task-based asynchronous programming (TAP) model. I have more information about Async WCF on my blog.
source share