Async CTP is very nice to use.
I saw some examples for windows phone, all using:
(Assembly AsyncCtpLibrary_Phone.dll, v2.0.50727, AsyncCtpExtensions).
var client = new WebClient();
string data = await client.DownloadStringTaskAsync(new Uri(url));
or something like the above code.
How can I use methods with async / await for my services? (WCF)
Today all methods work this way:
service.MyRequestCompleted += service_myRequestCompleted;
service.MyRequestAsync();
I can not find a way to use extension methods for services.
Unfortunetly, I haven’t found a good way to generalize this for any event, but it’s easy enough to adapt this for a particular event:
Then you can do:
I assume you see the pattern here, so you could adapt this so that it would work with some other event on some other type.
Oh, and if the event has arguments that are particularly important to you then you could make this return a
Task<T>instead of aTaskand instead of usingtcs.SetResult(null)you could use one of the parameters of the lambda to set the result.