Is correct order of WCF TCP messages guaranteed for multiple sending threads?
There is a single WCF connection using TCP. Two threads on the server write to this connection consecutively. Is it always guarantee开发者_如何学运维d that the first message gets processed by the client first? According to my understanding it should be guaranteed.
The 'channel' is sequential, so I think the answer here is Yes.
But with 2 (independent) threads, the meaning of 'first' is not well defined.
I think Henk's question (what is meant by the 'first' thread) is very interesting.
Given that threads can be suspended at any point, is it possible that Thread A could complete execution of the Send() method before Thread B, but Thread B is the first to return to user code?
From the point of view of the caller, it would look as if Thread B completed the send first.
I thought about this a bit more, and I believe this question is stupid. Why should WCF care at all which thread writes to a channel?
A write operation to the channel is atomic, and TCP transmission are guaranteed to be in order. Just as Henk pointed out, the channel is totally sequential. It will simply always happen on the client in the exact same order.
精彩评论