Created
April 29, 2020 17:23
-
-
Save dylanberry/e6daa5a533053c7e47ae47d3580bb1a0 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
public static class TaskUtilities | |
{ | |
#pragma warning disable RECS0165 // Asynchronous methods should return a Task instead of void | |
public static async void FireAndForgetSafeAsync(this Task task, Action<Exception> handleErrorAction = null) | |
#pragma warning restore RECS0165 // Asynchronous methods should return a Task instead of void | |
{ | |
try | |
{ | |
await task.ConfigureAwait(true); | |
} | |
catch (Exception ex) | |
{ | |
handleErrorAction?.Invoke(ex); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment