I am developing an application framework that will be utilized by Silverlight on the client side and .NET 4 on the server side. Internally, the framework has dictionary and queue data structures where multiple threads will be accessing the collections concurrently.
On the server side, I would like to utilize the ConcurrentDictionary and ConcurrentQueue classes available in the System.Collections.Concurrent namespace. These classes however are not implemented in Silverlight 4.
The two approaches I am considering are:
The first approach would allow me to just implement the Silverlight data structures that I need, but I worry about introducing disparities between my Silverlight implementation and the concurrent collection classes implemented in .NET 4.
The second approach would provide a consistent concurrent collection implementation both client and server side, but feels like I would be reinventing the wheel.
It does not appear that implementing the ConcurrentDictionary and ConcurrentQueue classes in Silverlight would be very difficult, but is there already a well adopted library of thread-safe collection classes for Silverlight?
The collection classes that are thread-safe in Java are Stack, Vector, Properties, Hashtable, etc.
The ConcurrentBag class is used to create a thread-safe, unordered collection of data in C#. The ConcurrentBag class is very similar to the List in C# and can be used as a thread-safe list in C#.
NET Framework 4 introduces the System. Collections. Concurrent namespace, which includes several collection classes that are both thread-safe and scalable. Multiple threads can safely and efficiently add or remove items from these collections, without requiring additional synchronization in user code.
The class library for Mono includes implementations of the various concurrent collections, and is licensed under the very permissive MIT license.
Try this out: http://ch.codeplex.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With