mirror of
https://github.com/bitwarden/android.git
synced 2025-01-09 09:47:36 +03:00
28 lines
888 B
C#
28 lines
888 B
C#
|
using System;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
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)
|
|||
|
{
|
|||
|
onException?.Invoke(ex);
|
|||
|
// TODO: Add app center exception handling in here, but we have to check whether we can add the AppCenter package to Core
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|