Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@CleanCoder
Created April 17, 2018 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CleanCoder/ace6862a361757024d2e2e599f0f55e8 to your computer and use it in GitHub Desktop.
Save CleanCoder/ace6862a361757024d2e2e599f0f55e8 to your computer and use it in GitHub Desktop.
internal static class TaskHelper
{
internal static Task<T> FromException<T>(Exception ex)
{
var completion = new TaskCompletionSource<T>();
completion.SetException(ex);
return completion.Task;
}
internal static Task<T> FromCancellation<T>()
{
var completion = new TaskCompletionSource<T>();
completion.SetCanceled();
return completion.Task;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment