示例#1
0
        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);
        }
示例#2
0
 // TODO: test error async
 private void asyncValue_handleLoad(IAsyncValue<int> asyncValue)
 {
     EnqueueTestComplete();
     Assert.AreEqual(LoadState.Loaded, asyncValue.State);
     Assert.AreEqual(MagicValue, asyncValue.Value);
 }
示例#3
0
        // TODO: test error async

        private void asyncValue_handleLoad(IAsyncValue <int> asyncValue)
        {
            EnqueueTestComplete();
            Assert.AreEqual(LoadState.Loaded, asyncValue.State);
            Assert.AreEqual(MagicValue, asyncValue.Value);
        }