Using HttpClient (P6) with Async, Await CTP!?

Topics: Web Api
Jan 3, 2012 at 4:59 AM

Hi All,

Since the HttpClient XXXAsync methods are not marked with the 'async' keyword (i.e. they are not awaitable for obvious reasons) what would be the recommended way to use them together with the AsyncCTP (CTP-SP1) so as to make the transition to .NET 4.5 practically transparent?

What is the recommended way forward here?

A simple example would be much appreciated.

Regards and all the best for 2012!

Jan 3, 2012 at 8:40 AM

I'm not clear why you think they aren't awaitable. They return Task, which makes them awaitable. From the external point of view, there's no such thing as a "method that is marked as async"; the async keyword in C# is an internal implementation detail of the method and is not surfaced anywhere in its signature.

Jan 3, 2012 at 11:04 AM

Ok, perhaps my terminology is not quite correct...

I have managed to get the async/await pattern working, I think I had a few wires crossed with regards to AsyncCTP assembly.

It looks and feels good... thanks.