using System; using System.Threading.Tasks; namespace Discord { internal static class TaskCompletionSourceExtensions { public static Task SetResultAsync(this TaskCompletionSource source, T result) => Task.Run(() => source.SetResult(result)); public static Task TrySetResultAsync(this TaskCompletionSource source, T result) => Task.Run(() => source.TrySetResult(result)); public static Task SetExceptionAsync(this TaskCompletionSource source, Exception ex) => Task.Run(() => source.SetException(ex)); public static Task TrySetExceptionAsync(this TaskCompletionSource source, Exception ex) => Task.Run(() => source.TrySetException(ex)); public static Task SetCanceledAsync(this TaskCompletionSource source) => Task.Run(() => source.SetCanceled()); public static Task TrySetCanceledAsync(this TaskCompletionSource source) => Task.Run(() => source.TrySetCanceled()); } }