namespace Core
{
public static class TaskExtensions
{
///
/// Fires a task and ignores any exception.
/// See http://stackoverflow.com/a/22864616/344182
///
/// The task to be forgotten.
/// Action to be called on exception.
public static async void FireAndForget(this Task task, Action onException = null)
{
try
{
await task.ConfigureAwait(false);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
onException?.Invoke(ex);
}
}
}
}