0

I have a WCF duplex channel. In the callback, the WCF service shall notify the client and asynchronously wait till the client has completely processed the notification.

In this article I found how I could implement the callback interface:

public interface IClientCallback
{
    [OperationContract(IsOneWay = true)]
    Task NotifySomething();
}

// call from WCF service
await clientCallback.NotifySomething();

This is exacly what I need, but I'm a little surprised, because I thought that one way operations can only have void as return type.

See also this MSDN article:

One-way methods must not return a value or have ref or out parameters

So is the above code really the correct solution for my problem?

MaDev
  • 151
  • 9
  • asynchronously wait ..What do you mean?.Can you be a little brief . – Hameed Syed Nov 27 '17 at 13:39
  • Method that returns `Task` (and not `Task`) is asynchornous analog of method that returns `void`, so that's fine. Note that for one-way operations no response is expected from the other side, so it will not "wait till the client has completely processed the notification". – Evk Nov 27 '17 at 13:51
  • @Hameed: With "asynchronously wait" I mean that the service is not blocked while it waits that the client has processed the notification. – MaDev Nov 27 '17 at 14:14
  • @Evk: So how long would the `await clientCallback.NotifySomething()` actually wait? – MaDev Nov 27 '17 at 14:18
  • I did not touch WCF for years so my knowledge about that is rusty. That said, I would expect it will wait until request message is sent to client, but it will not wait for response from client to be received. – Evk Nov 27 '17 at 14:20

0 Answers0