简体   繁体   中英

how to let WCF service to send messages to the client without calling its method from the service?

Im new to WCF and what i know till now that i can use a method from WCF service and it returns some value back, but i was wondering if i used a and i want to send a message like "Job Complete" to the client after it got finished, how would i do that? 并且想向客户端发送“ Job Complete”之类的消息完成后,我该怎么办?
Should i use AutoResetEvent and wait for the backgroundworker until completes then resetEvent.Set() to let the method on the main thread to return the message?
i need that thread not to get busy, it should be ready for any other commands i request from the client. so any ideas?

I've figured it out, well i couldn't send message back from service without calling the method but when i changed the attributes of the service behavior from ConcurrencyMode = ConcurrencyMode.Single to ConcurrencyMode = ConcurrencyMode.Multiple it went multithreaded and the result :
the method runs in a new thread because of this attribute and i can send other request while that thread is working and when it finishs it returns me the message/result.

[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple, InstanceContextMode = InstanceContextMode.PerSession)]
public class FileManagerService : IFileManager

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM