Async and Await in WPF
In our last video, we looked at using the async and await keywords in a console application. This week’s video uses async and await in a WPF application.
First we create a simple event handler using async and await. Then we simulate what happens behind-the-scenes with await by implementing the same behavior using continuation tasks. Just like await, we capture the SynchronizationContext and use the Post method to run the continuation on the UI thread.
Next we use DBpedia’s SPARQL endpoint to asynchronously execute a query against its structured data from Wikipedia. We then see what happens when an exception is thrown in an awaited task.
Stephen Toub has an excellent three-part article (2) (3) on await, SynchronizationContext and console apps.
June 03, 2013