提交 89854eea 编写于 作者: T tanghai

ETCancellationTokenSource在Cancel之后调用Dispose,防止using的用法取消了却没调用Dispose

上级 5acc1e2b
......@@ -27,32 +27,15 @@ namespace ETModel
public void Cancel()
{
if (this.CancellationTokenSource == null)
{
return;
}
CancellationTokenSource cts = this.CancellationTokenSource;
this.CancellationTokenSource = null;
cts?.Cancel();
this.CancellationTokenSource.Cancel();
this.Dispose();
}
public async ETVoid CancelAfter(long afterTimeCancel)
{
if (this.CancellationTokenSource == null)
{
return;
}
await Game.Scene.GetComponent<TimerComponent>().WaitAsync(afterTimeCancel);
if (this.CancellationTokenSource == null)
{
return;
}
CancellationTokenSource cts = this.CancellationTokenSource;
this.CancellationTokenSource = null;
cts?.Cancel();
this.CancellationTokenSource.Cancel();
this.Dispose();
}
public CancellationToken Token
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册