This commit is contained in:
CortexCore
2023-06-05 16:25:06 +08:00
parent 9027120bb8
commit 4565ff2e35
2947 changed files with 0 additions and 0 deletions

33
Core/Extensions/Task.cs Normal file
View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using Cysharp.Threading.Tasks;
namespace BITKit
{
public static partial class TaskHelper
{
public static async Task WaitUntil(Func<bool> func)
{
try
{
await WaitUntil(func, BITApp.CancellationTokenSource.Token);
}
catch (System.Exception)
{
}
}
public static async Task WaitUntil(Func<bool> func, CancellationToken cancelToken)
{
while (func is not null && func() is false)
{
cancelToken.ThrowIfCancellationRequested();
await Task.Delay(64);
}
}
}
}