On a scheduled interval I need to call a WCF service call another WCF Service asyncronously. Scheduling a call to a WCF service I have worked out.
What I think I ne
Be sure to carefully test the way a OneWay WCF call performs. I've seen it stall when you reach X number of simultaneous calls, as if WCF actually does wait for the call to end.
A safer solution is to have the "target" code return control ASAP: Instead of letting it process the call fully, make it only put the data into a queue and return. Have another thread poll that queue and work on the data asynchronously.
And be sure to apply a thread safety mechanism to avoid clashes between the two threads working on that queue.
Set the IsOneWay property of the OperationContract attribute to true on the WCF method that you are calling to. This tells WCF that the call only matters for one direction and the client won't hang around for the method to finish executing.
Even when calling BeginInvoke your client code will still hang-out waiting for the server method to finish executing but it will do it on a threadpool thread.
[ServiceContract]
interface IWCFContract
{
[OperationContract(IsOneWay = true)]
void CallMe()
}
The other way to do what you want is to have the WCF service spin its work off onto a background thread and return immediately.
Don't use BeginInvoke or even a thread for your pattern. Make sure you decorate your classes with the AsyncPattern according to Microsoft website, otherwise your Async delegates and threads will be run in a synchronous mode. WCF forces this behavior. This info was posted by another op who found a solution to blocking callbacks question on stack .. sorry but I do not remember the link.