简体   繁体   中英

How the wcf blocks the client when IsOneWay=false?

Host : has a function which is : IsOneWay=False

this function when called - pops a MessageBox in the HOST .

Client : has a winform that has only button that calls the Host's func.

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).

but if the IsOneWay= False - then he let me press just once ( until i release the MesageBox on the Host)..

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.

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. 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. 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=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...

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