0

I have WCF service which sends messages to its clients. I would like to call callback methods asynchronously. I have read this answer: WCF asynchronous callback

But there is one problem. When I am generating IMyServiceCallback from WebServiceReference it contains both synchronous and asynchronous methods (while on the service side there is callback contract with only asynchronous methods - BeginCallbackMethod and EndCallbackMethod). What is more when I call from MyService to calback BeginCallbackMethod, on the client side (in callback implementation) it is using synchronous CallbackMethod. The question is why? Is there any way to configure it?

Community
  • 1
  • 1
rideronthestorm
  • 727
  • 1
  • 13
  • 32

1 Answers1

0

By default WCF will call the synchronous version of an operation if both sync and async are present; I don't know how (or if) you can change that logic, but one thing you can do is to simply remove the synchronous method from the generated callback interface. The callback code should continue to work, and it will use the asynchronous implementation instead. You can also just remove the [OperationContract] attribute from the synchronous version, to the same effect.

carlosfigueira
  • 85,035
  • 14
  • 131
  • 171