简体   繁体   English

IsOneWay = false时,wcf如何阻止客户端?

[英]How the wcf blocks the client when IsOneWay=false?

Host : has a function which is : IsOneWay=False 主机 :具有以下功能: IsOneWay=False

this function when called - pops a MessageBox in the HOST . 调用此函数时- 在主机中弹出MessageBox

Client : has a winform that has only button that calls the Host's func. 客户端 :有一个winform, 只有一个按钮可以调用主机的功能。

if the function in the host IsOneWay= true - i can multi press the client button ( he doesnt care if i released the messagebox on the Host or not). 如果在主机IsOneWay = 真正的功能-我可以多按客户按钮(他不关心 ,如果我发布了消息框上的主机或没有)。

but if the IsOneWay= False - then he let me press just once ( until i release the MesageBox on the Host).. 如果IsOneWay = -然后他让我按只有一次直到我松开主机的MesageBox)..

host does he do that ?

How the Client knows that he should be blocked until the user releases the MessageBox on the Host side ?

The WCF host isn't responding to the client until the message box is dismissed. 在关闭消息框之前,WCF主机不会响应客户端。

If you were to break into the debugger on the client side you should see that your code is still within the WCF call to the host. 如果要闯入客户端的调试器,则应该看到代码仍在对主机的WCF调用中。 If you waited long enough it would eventually time out. 如果您等待了足够长的时间,它将最终超时。 WCF can do this because IsOneWay=false requires the server to return before the client can continue executing. WCF可以执行此操作,因为IsOneWay=false要求服务器先返回,然后客户端才能继续执行。 When IsOneWay=true the client sends the request and the server responds right away with success allowing the client to continue (before any server code is executed). IsOneWay=true ,客户端发送请求,服务器立即成功响应,允许客户端继续执行(在执行任何服务器代码之前)。

IsOneWay=false
   Client       Server
   ------    |  ------
1. click    --> method --> messagebox waits for OK
(client can't continue until server returns)
2. continue <-- method <-- user dismisses messagebox

IsOneWay=true
   Client     Server
   ------  |  ------
1. click  -->  method --> messagebox waits for OK
(client continues regardless of server state)
2. click  -->  method --> 2nd messagebox waits for OK
                          user dismisses messageboxes
etc...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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