diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2017-10-04 13:41:49 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-04 13:41:49 +0200 |
commit | ebae8a8c9f15425da8f07442642ca308f3c6612c (patch) | |
tree | 4fcdc67df2c51e5b7840866397fa6b2f15b773e9 | |
parent | ec9c592ccbb3bd8d23c3072a06771a6bd105202c (diff) | |
parent | f693013b13c548cae2e5cba3d5ec235faac58eb9 (diff) |
Merge pull request #12801 from chrisdunelm/fixregister
C# De-register cancellation token
-rw-r--r-- | src/csharp/Grpc.Core/Internal/AsyncCall.cs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs index 17109de587..09fb722c81 100644 --- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs +++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs @@ -34,6 +34,9 @@ namespace Grpc.Core.Internal readonly CallInvocationDetails<TRequest, TResponse> details; readonly INativeCall injectedNativeCall; // for testing + // Dispose of to de-register cancellation token registration + IDisposable cancellationTokenRegistration; + // Completion of a pending unary response if not null. TaskCompletionSource<TResponse> unaryResponseTcs; @@ -320,6 +323,7 @@ namespace Grpc.Core.Internal protected override void OnAfterReleaseResources() { details.Channel.RemoveCallReference(this); + cancellationTokenRegistration?.Dispose(); } protected override bool IsClient @@ -405,7 +409,7 @@ namespace Grpc.Core.Internal var token = details.Options.CancellationToken; if (token.CanBeCanceled) { - token.Register(() => this.Cancel()); + cancellationTokenRegistration = token.Register(() => this.Cancel()); } } |