Example #1
0
        public static bool TrySetResultAsync <T>(this TaskCompletionSource <T> tcs, T result)
        {
#if NET45
            return(SimpleSynchronizationContext.Enqueue(() => tcs.TrySetResult(result)));
#else
            return(tcs.TrySetResult(result));
#endif
        }
Example #2
0
        public static bool TrySetCanceledAsync <T>(this TaskCompletionSource <T> tcs)
        {
#if NET45
            return(SimpleSynchronizationContext.Enqueue(() => tcs.TrySetCanceled()));
#else
            return(tcs.TrySetCanceled());
#endif
        }
Example #3
0
        public static bool TrySetExceptionAsync <T>(this TaskCompletionSource <T> tcs, Exception ex)
        {
#if NET45
            return(SimpleSynchronizationContext.Enqueue(() => tcs.TrySetException(ex)));
#else
            return(tcs.TrySetException(ex));
#endif
        }