public static Task <T> AsTask <T>(this IAsyncValue <T> asyncValue) { var tcs = new TaskCompletionSource <T>(TaskCreationOptions.None); asyncValue.OnCancel += tcs.SetCanceled; asyncValue.OnAbort += () => tcs.SetException(new Exception("aborted")); asyncValue.OnComplete += () => tcs.SetResult(asyncValue.Value); return(tcs.Task); }
// TODO: test error async private void asyncValue_handleLoad(IAsyncValue<int> asyncValue) { EnqueueTestComplete(); Assert.AreEqual(LoadState.Loaded, asyncValue.State); Assert.AreEqual(MagicValue, asyncValue.Value); }
// TODO: test error async private void asyncValue_handleLoad(IAsyncValue <int> asyncValue) { EnqueueTestComplete(); Assert.AreEqual(LoadState.Loaded, asyncValue.State); Assert.AreEqual(MagicValue, asyncValue.Value); }