using System; using System.Threading.Tasks; namespace AnotherReplayReader.Utils { internal static class CancellableTaskExtensions { public static async Task IgnoreCancel(this Task task) { try { await task.ConfigureAwait(false); } catch (OperationCanceledException) { } } public static void Forget(this Task task) { const TaskContinuationOptions flags = TaskContinuationOptions.NotOnRanToCompletion | TaskContinuationOptions.ExecuteSynchronously; task.ContinueWith(t => t.Exception?.Handle(_ => true), flags); } } }