Created
April 17, 2018 03:31
-
-
Save CleanCoder/ace6862a361757024d2e2e599f0f55e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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