mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
22 lines
501 B
C#
22 lines
501 B
C#
namespace ET
|
|
{
|
|
public static class ETCancelationTokenHelper
|
|
{
|
|
public static async ETTask CancelAfter(this ETCancellationToken self, Fiber fiber, long afterTimeCancel)
|
|
{
|
|
if (self.IsCancel())
|
|
{
|
|
return;
|
|
}
|
|
|
|
await fiber.TimerComponent.WaitAsync(afterTimeCancel);
|
|
|
|
if (self.IsCancel())
|
|
{
|
|
return;
|
|
}
|
|
|
|
self.Cancel();
|
|
}
|
|
}
|
|
} |