Threading Issue with WCF Service

Posted by helixed on Stack Overflow See other posts from Stack Overflow or by helixed
Published on 2011-11-22T09:16:08Z Indexed on 2011/11/22 9:50 UTC
Read the original article Hit count: 584

Filed under:
|
|
|

I'm new to both WCF and threading, so please bear with me. I have a WCF service set up. The service has multiple threads, all of which act upon a single array. This works without a problem so far. However, this service has a method, which, when called, will return the array. My questions:

  1. The array is serialized when it is transferred to the client by WCF. Is this a thread safe operation? In other words, can I count on WCF to block all threads from accessing this array while it's being serialized?

  2. If I can't count on WCF to do this, then how can I implement it manually? I don't really understand how WCF would facilitate this since the serialization happens after I return from my method call. How can I guarantee a thread will not modify the array after it's been returned by my method but before WCF serializes it?

© Stack Overflow or respective owner

Related posts about c#

Related posts about multithreading