4

Is possible to send data from WCF service to client without request ? For example in WCF I have function which in loop send data. How can I make that functionality ?

Szymson
  • 990
  • 1
  • 13
  • 28

3 Answers3

6

This can be achieved with a Full Duplex contract. Where you will hold reference to the client in the service instance and then you can use the CallbackContract to send messages to the client who has registered to the service.

Answering this question with a clear code example would require more of a blog post than stackoverflow reply. So just linking a very simplified example which you can find from here.

Janne Matikainen
  • 5,061
  • 15
  • 21
1

You could solve this with "long-polling"

This could help you: How do I implement basic "Long Polling"?

But there is the problem, that the client has to send a request first.

Community
  • 1
  • 1
Patrick
  • 161
  • 1
  • 6
0

It sounds like you're asking about pushing data from server to client rather than having the client request it (pull)

You can use technologies such as SignalR in conjunction with WCF to accomplish the sort of thing you're asking about.

Kritner
  • 13,557
  • 10
  • 46
  • 72