#region ========================================================================= USING ===================================================================================== using System; using System.Diagnostics; using System.Threading.Tasks; #endregion namespace Lumina.Application.Common.Utilities; /// /// Task extension method to handle exceptions (avoid littering whole project with try...catch'es). /// public static class TaskUtilities { /// /// Extends Task by providing exception handling when a task is invoked on a void method (not awaited). /// /// The task to be awaited. /// Optional continuation when finishes. public static async void FireAndForgetSafeAsync(this Task task, Action? onComplete = null) { try { await task; } catch (Exception ex) { Debug.WriteLine(ex); } finally { onComplete?.Invoke(); } } }