diff options
author | 2017-11-30 10:54:42 -0800 | |
---|---|---|
committer | 2017-11-30 10:54:42 -0800 | |
commit | 10f2790f7fedb7b54889c9ba8297a9e127edb143 (patch) | |
tree | 899151af9bc4ab60aac48ab67de4e84c1cd8062a /src/csharp/Grpc.Core/Internal/ServerRequestStream.cs | |
parent | c354269ba7bd1f6dfe9c86ba18f38fc8e346dcfc (diff) | |
parent | 5f662537deb01539a204273977c7e32394fc3454 (diff) |
Merge branch 'master' into execctx
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/ServerRequestStream.cs')
-rw-r--r-- | src/csharp/Grpc.Core/Internal/ServerRequestStream.cs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs index c65b960afb..058dddb7eb 100644 --- a/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs +++ b/src/csharp/Grpc.Core/Internal/ServerRequestStream.cs @@ -49,13 +49,14 @@ namespace Grpc.Core.Internal public async Task<bool> MoveNext(CancellationToken token) { - if (token != CancellationToken.None) + + var cancellationTokenRegistration = token.CanBeCanceled ? token.Register(() => call.Cancel()) : (IDisposable) null; + using (cancellationTokenRegistration) { - throw new InvalidOperationException("Cancellation of individual reads is not supported."); + var result = await call.ReadMessageAsync().ConfigureAwait(false); + this.current = result; + return result != null; } - var result = await call.ReadMessageAsync().ConfigureAwait(false); - this.current = result; - return result != null; } public void Dispose() |