mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-18 21:20:10 +00:00
Fix channel's cancellationTokenRegistration does not handle correctly
This commit is contained in:
@@ -368,8 +368,8 @@ namespace Cysharp.Threading.Tasks
|
|||||||
readonly SingleConsumerUnboundedChannelReader parent;
|
readonly SingleConsumerUnboundedChannelReader parent;
|
||||||
CancellationToken cancellationToken1;
|
CancellationToken cancellationToken1;
|
||||||
CancellationToken cancellationToken2;
|
CancellationToken cancellationToken2;
|
||||||
CancellationTokenRegistration CancellationTokenRegistration1;
|
CancellationTokenRegistration cancellationTokenRegistration1;
|
||||||
CancellationTokenRegistration CancellationTokenRegistration2;
|
CancellationTokenRegistration cancellationTokenRegistration2;
|
||||||
|
|
||||||
T current;
|
T current;
|
||||||
bool cacheValue;
|
bool cacheValue;
|
||||||
@@ -395,12 +395,12 @@ namespace Cysharp.Threading.Tasks
|
|||||||
|
|
||||||
if (this.cancellationToken1.CanBeCanceled)
|
if (this.cancellationToken1.CanBeCanceled)
|
||||||
{
|
{
|
||||||
this.cancellationToken1.RegisterWithoutCaptureExecutionContext(CancellationCallback1Delegate, this);
|
this.cancellationTokenRegistration1 = this.cancellationToken1.RegisterWithoutCaptureExecutionContext(CancellationCallback1Delegate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.cancellationToken2.CanBeCanceled)
|
if (this.cancellationToken2.CanBeCanceled)
|
||||||
{
|
{
|
||||||
this.cancellationToken2.RegisterWithoutCaptureExecutionContext(CancellationCallback2Delegate, this);
|
this.cancellationTokenRegistration2 = this.cancellationToken2.RegisterWithoutCaptureExecutionContext(CancellationCallback2Delegate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
@@ -428,8 +428,8 @@ namespace Cysharp.Threading.Tasks
|
|||||||
|
|
||||||
public UniTask DisposeAsync()
|
public UniTask DisposeAsync()
|
||||||
{
|
{
|
||||||
CancellationTokenRegistration1.Dispose();
|
cancellationTokenRegistration1.Dispose();
|
||||||
CancellationTokenRegistration2.Dispose();
|
cancellationTokenRegistration2.Dispose();
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user