改了一亿个东西,修了一亿个 BUG
This commit is contained in:
23
Utils/CancellableTaskExtensions.cs
Normal file
23
Utils/CancellableTaskExtensions.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user