1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-13 06:43:17 +00:00
Files
mobile/src/Samples/EmbeddedIOSNavigationIssue/Core/TaskExtensions.cs
2023-12-26 18:47:59 -03:00

25 lines
741 B
C#

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