1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-29 04:07:37 +02:00
bitwarden-mobile/src/Core/Utilities/TaskExtensions.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
833 B
C#
Raw Normal View History

using System;
using System.Threading.Tasks;
using Bit.Core.Services;
namespace Bit.Core.Utilities
{
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)
{
LoggerHelper.LogEvenIfCantBeResolved(ex);
onException?.Invoke(ex);
}
}
}
}