Chris
Chris

Reputation: 2991

Calling Close() on Service Proxy blocks after One Way WCF call

I have a simple Fire and Forget service operation that works fine and doesn't block. However, when I try to close the service proxy, it will block until the one-way call completes. Is this expected behavior?

Client Code:

var serviceProxy = new MyServiceProxy();
serviceProxy.OneWayCall();
serviceProxy.Close();  // This blocks until OneWayCall() is finished.

Service:

[ServiceContract]
public interface IMyService {
   [OperationContract(IsOneWay = true)]
   void OneWayCall();
}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyService : IMyService {
   public void OneWayCall() {
      // Stuff and things
   }
}

Upvotes: 1

Views: 1732

Answers (2)

Jakub Kaleta
Jakub Kaleta

Reputation: 1780

For completeness' sake; here is what Microsoft has to say about this behavior:

Clients Blocking with One-Way Operations

Upvotes: 1

Tanner
Tanner

Reputation: 22753

Yes - depending on the binding/configuration your service is using and if you are using sessions in any way. See the below link for information on configurations that lead to blocking:

WCF Best Practice #5: One-way is not always really one-way

Hope that helps

Upvotes: 3

Related Questions