Last active
March 18, 2022 16:03
Await extension method for Task
This file contains hidden or 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
public static class TaskExtensions | |
{ | |
public async static void Await(this Task task, Action onCompleted, Action<Exception> onError) | |
{ | |
try | |
{ | |
await task; | |
onCompleted?.Invoke(); | |
} | |
catch (Exception ex) | |
{ | |
onError?.Invoke(ex); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment