Last active
March 18, 2022 16:03
-
-
Save nor0x/c70f7139a458b3d415c63683c6a78bfe to your computer and use it in GitHub Desktop.
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