void return methods in WCF (IsOneWay)

Don’t forget, if you’re implementing a fire and forget style method call in WCF, to mark it as one way.

In situations where you do not need or want to return a value from the server or handle exceptions from the client. You must mark the method’s operation contract as IsOneWay=true.

For example (if this is the service contract)

[ServiceContract]
public interface IProjectManager
{
   [OperationContract(IsOneWay=true)]
   void Run();
}

Without the IsOneWay=true the method will get called by the client but will block and may eventually timeout.

Basically with a one way operation the client calls the service and the service may queue the call to be dispatched one at a time. If the number of queued calls exceeds the queue’s capacity the client will block. In the case of a one way call the message is queued but the client unblocked. It is not an async call but may appear that way.

By default IsOneWay is false, hence the need to add the option to the attribute explicitly.