wcf - Any way to tell if a DuplexClientBase is busy? -


i looking @ microsoft's duplex wcf sample:

it starts here interesting bit here @ end client.

  // wait callback messages complete before   // closing.   system.threading.thread.sleep(5000);    // close wcf client.   wcfclient.close();   console.writeline("done!"); 

if take out sleep, exception

the session closed before message transfer complete.

so client knows there's stuff in air, there way ask current status? there's state defines whether it's open or closed (i.e. connected not active).

this not entirely true. methods one-way method calls. so, when call service client, call (or set of calls) completed. in other words, "message" has been delivered service , there no expectation response since one-way. might callback on callback contract...it might not.

when setup duplex channel, you're standing endpoint service call on (client becomes service essentially). if close client, if/when service decides call back, communication exception occur. that's way message exchange pattern works.

you sort of answered own question. is, when check status either open, closed (or faulted). when you're using duplex channel, open in case means there potentially "activity" on channel. that's why sleep there - allow service time call back. if @ sdk sample (http://msdn.microsoft.com/en-us/library/vstudio/ms752216(v=vs.110).aspx), it's doing same thing except sits there waiting press enter before closes client application.

so, in real application (not console based sample these are), either keep client proxy active or change message exchange pattern request/reply pattern.


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -