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 }
public static bool TrySetCanceledAsync <T>(this TaskCompletionSource <T> tcs) { #if NET45 return(SimpleSynchronizationContext.Enqueue(() => tcs.TrySetCanceled())); #else return(tcs.TrySetCanceled()); #endif }
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 }