aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/csharp/Grpc.Core/Internal/AsyncCall.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/AsyncCall.cs')
-rw-r--r--src/csharp/Grpc.Core/Internal/AsyncCall.cs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/csharp/Grpc.Core/Internal/AsyncCall.cs b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
index 2caba260b3..016e1b8587 100644
--- a/src/csharp/Grpc.Core/Internal/AsyncCall.cs
+++ b/src/csharp/Grpc.Core/Internal/AsyncCall.cs
@@ -1,6 +1,6 @@
#region Copyright notice and license
-// Copyright 2015-2016, Google Inc.
+// Copyright 2015, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
@@ -258,9 +258,19 @@ namespace Grpc.Core.Internal
lock (myLock)
{
GrpcPreconditions.CheckNotNull(completionDelegate, "Completion delegate cannot be null");
- CheckSendingAllowed();
+ CheckSendingAllowed(allowFinished: true);
- call.StartSendCloseFromClient(HandleHalfclosed);
+ if (!disposed && !finished)
+ {
+ call.StartSendCloseFromClient(HandleSendCloseFromClientFinished);
+ }
+ else
+ {
+ // In case the call has already been finished by the serverside,
+ // the halfclose has already been done implicitly, so we only
+ // emit the notification for the completion delegate.
+ Task.Run(() => HandleSendCloseFromClientFinished(true));
+ }
halfcloseRequested = true;
sendCompletionDelegate = completionDelegate;