From 70385c41159c88fb7f22e593889f01ac3a2da5cf Mon Sep 17 00:00:00 2001 From: neuecc Date: Sun, 24 May 2020 00:19:13 +0900 Subject: [PATCH] Fix channel's cancellationTokenRegistration does not handle correctly --- .../Assets/Plugins/UniTask/Runtime/Channel.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/Channel.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/Channel.cs index e391d19..5a484fd 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/Channel.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/Channel.cs @@ -368,8 +368,8 @@ namespace Cysharp.Threading.Tasks readonly SingleConsumerUnboundedChannelReader parent; CancellationToken cancellationToken1; CancellationToken cancellationToken2; - CancellationTokenRegistration CancellationTokenRegistration1; - CancellationTokenRegistration CancellationTokenRegistration2; + CancellationTokenRegistration cancellationTokenRegistration1; + CancellationTokenRegistration cancellationTokenRegistration2; T current; bool cacheValue; @@ -395,12 +395,12 @@ namespace Cysharp.Threading.Tasks if (this.cancellationToken1.CanBeCanceled) { - this.cancellationToken1.RegisterWithoutCaptureExecutionContext(CancellationCallback1Delegate, this); + this.cancellationTokenRegistration1 = this.cancellationToken1.RegisterWithoutCaptureExecutionContext(CancellationCallback1Delegate, this); } if (this.cancellationToken2.CanBeCanceled) { - this.cancellationToken2.RegisterWithoutCaptureExecutionContext(CancellationCallback2Delegate, this); + this.cancellationTokenRegistration2 = this.cancellationToken2.RegisterWithoutCaptureExecutionContext(CancellationCallback2Delegate, this); } running = true; @@ -428,8 +428,8 @@ namespace Cysharp.Threading.Tasks public UniTask DisposeAsync() { - CancellationTokenRegistration1.Dispose(); - CancellationTokenRegistration2.Dispose(); + cancellationTokenRegistration1.Dispose(); + cancellationTokenRegistration2.Dispose(); return default; }