Awaiting an Asynchronous Operation
Windows Runtime APIs are designed to make it really hard to block a UI thread. Whenever the Windows Runtime exposes a potentially-long-running operation, it does so with an asynchronous method that performs its work on a background thread. You can easily identify such methods by their
Async suffix. And they are everywhere. For example, showing a
MessageDialog (discussed in Chapter 14, “Other Controls”) requires a call to
MessageDialog dialog = new MessageDialog("Title"); IAsyncOperation<IUICommand> operation = dialog.ShowAsync(); // The next line of code runs in parallel with ShowAsync's background work MoreCode();
Asynchronous methods in the Windows Runtime return one ...