24 lines
668 B
C#
24 lines
668 B
C#
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);
|
|
}
|
|
}
|
|
}
|