Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Serialization of Dictionary<> and Thread Synch

 
 
Old 10-25-2006   #1 (permalink)
Jon


 
 

Serialization of Dictionary<> and Thread Synch

Hi

I may be being stupid here (as I haven't tried it yet) but if I have WCF
Service which returns a static Dictionary<K,V> object (which I understand is
serializable in WCF) and another thread were to modify that collection while
it were serializing, what would happen?

Does the framework take care of it (e.g. snapshot the collection), or would
I need to synchronize the addition/removal of Dictionary objects with the
service that returns the Dictionary to calling clients?

Thanks

My System SpecsSystem Spec
Old 10-25-2006   #2 (permalink)
Arkady Frenkel


 
 

Re: Serialization of Dictionary<> and Thread Synch

In such cases I don't take a chance and copy object ( Dictionary in your
case ) under Sync object ( Lock()/Monitor()... )
before return copied object from service, so I'm calm that object will be
returned to client without changes

Arkady

"Jon" <Jon@discussions.microsoft.com> wrote in message
news:48244107-16D2-406E-BCA5-02A117E3038E@microsoft.com...
> Hi
>
> I may be being stupid here (as I haven't tried it yet) but if I have WCF
> Service which returns a static Dictionary<K,V> object (which I understand
> is
> serializable in WCF) and another thread were to modify that collection
> while
> it were serializing, what would happen?
>
> Does the framework take care of it (e.g. snapshot the collection), or
> would
> I need to synchronize the addition/removal of Dictionary objects with the
> service that returns the Dictionary to calling clients?
>
> Thanks



My System SpecsSystem Spec
Old 10-27-2006   #3 (permalink)
Steve B.


 
 

Re: Serialization of Dictionary<> and Thread Synch

If the serialization process use an enumerator on the dictionnary while it
serialize... The dictionnary.add method will crash, doesn't it ?


"Arkady Frenkel" <arkadyf@hotmailxdotx.com> a écrit dans le message de news:
uC5PLtF%23GHA.4468@TK2MSFTNGP05.phx.gbl...
> In such cases I don't take a chance and copy object ( Dictionary in your
> case ) under Sync object ( Lock()/Monitor()... )
> before return copied object from service, so I'm calm that object will be
> returned to client without changes
>
> Arkady
>
> "Jon" <Jon@discussions.microsoft.com> wrote in message
> news:48244107-16D2-406E-BCA5-02A117E3038E@microsoft.com...
>> Hi
>>
>> I may be being stupid here (as I haven't tried it yet) but if I have WCF
>> Service which returns a static Dictionary<K,V> object (which I understand
>> is
>> serializable in WCF) and another thread were to modify that collection
>> while
>> it were serializing, what would happen?
>>
>> Does the framework take care of it (e.g. snapshot the collection), or
>> would
>> I need to synchronize the addition/removal of Dictionary objects with the
>> service that returns the Dictionary to calling clients?
>>
>> Thanks

>
>



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
How do the current thread get thread notification of OS intruption .NET General
how do I synch windows mail calendar with iphone since Outlook is only option for calendar synch Vista mail
Start a new thread from an existing thread, which was started from atimer .NET General
XML Serialization .NET General
Dictionary<TKey,TValue> as a Dictionary key in C# 2.0 .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46