diff options
Diffstat (limited to 'src/csharp/Grpc.Core/Server.cs')
-rw-r--r-- | src/csharp/Grpc.Core/Server.cs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/csharp/Grpc.Core/Server.cs b/src/csharp/Grpc.Core/Server.cs index de10be39ab..8e818885d1 100644 --- a/src/csharp/Grpc.Core/Server.cs +++ b/src/csharp/Grpc.Core/Server.cs @@ -143,7 +143,8 @@ namespace Grpc.Core Preconditions.CheckState(!shutdownRequested); shutdownRequested = true; } - handle.ShutdownAndNotify(HandleServerShutdown); + + handle.ShutdownAndNotify(GetCompletionQueue(), HandleServerShutdown); await shutdownTcs.Task; handle.Dispose(); } @@ -159,8 +160,22 @@ namespace Grpc.Core } } - public void Kill() + /// <summary> + /// Requests server shutdown while cancelling all the in-progress calls. + /// The returned task finishes when shutdown procedure is complete. + /// </summary> + public async Task KillAsync() { + lock (myLock) + { + Preconditions.CheckState(startRequested); + Preconditions.CheckState(!shutdownRequested); + shutdownRequested = true; + } + + handle.ShutdownAndNotify(GetCompletionQueue(), HandleServerShutdown); + handle.CancelAllCalls(); + await shutdownTcs.Task; handle.Dispose(); } |