So as to enable aysc callbacks to the clients, I need to add the Begin/End methods to the interface that is defined as the CallbackContract on my service. (I am using a she
As DxCK siad the type that is passed to OperationContext.Current.GetCallbackChannel
However I need to use a different interface for the callbacks so I can add the Begin/End methods needed to support aysc callbacks.
So firstly my new callback interface.
[ServiceContract]
public interface IClientWithAsyncMethods : IClient
{
[OperationContract(
AsyncPattern = true,
Action = "ReceiveMessage",
ReplyAction = "ReceiveMessageResponse")]
IAsyncResult BeginReceiveMessage(SimMessage message,
AsyncCallback callback, object asyncState);
void EndReceiveMessage(IAsyncResult asyncResult);
}
Then need to define a new interface for my service to implment:
[ServiceContract(CallbackContract = typeof(IClientWithAsyncMethods))]
public interface IEngineManagerWithAsyncCallbacks : IEngineManager
{
}
The only change to to refare to the new callback interface as the CallbackContract, this is OK as IClientWithAsyncMethods is a subtype of IClient.
Then the last step is to change the serve implementation to use to the service interface:
>()
The rest is just calling the aysc method in the normal way.