InvalidOperationException When Working With IAsyncOperation<TResult>

Thursday, November 27, 2014

WinRT introduced the concept of IAsyncOperation for working with Asynchrounous code. the IAsyncOperation is merely a representation of an Async Operation (a future in the computer science lingo) and as the same meaning as hte .NET System.Threading.Tasks.Task class, so its not suprising to see that you can convert IAsyncOpertion<TResult> to Task<TResult> IAsyncOperation<int> asyncOperation=...; Task<int> task = operation.AsTask(); .NET Tasks has the Result property which gets the value of the async oprtation if it finished or wait till the value is available – this of course can cause the calling thread to freeze until the value is returned. IAsyncOperation has something...