Skip to content

Instantly share code, notes, and snippets.

@nor0x
Last active March 18, 2022 16:03
Show Gist options
  • Save nor0x/c70f7139a458b3d415c63683c6a78bfe to your computer and use it in GitHub Desktop.
Save nor0x/c70f7139a458b3d415c63683c6a78bfe to your computer and use it in GitHub Desktop.
Await extension method for Task
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