9

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:

  1. Decompile the ConcurrentDictionary and ConcurrentQueue classes and implement them in a Silverlight class library. These would be scoped using the System.Collections.Concurrent namespace.
  2. Implement the custom thread-safe collection classes I need in a shared library (or find a reliable Silverlight thread-safe collection implementation) that can be used both server and client side.

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?

dsolimano
  • 8,870
  • 3
  • 48
  • 63
Oppositional
  • 11,141
  • 6
  • 50
  • 63

2 Answers2

6

Try this out: http://ch.codeplex.com/

hazzik
  • 13,019
  • 9
  • 47
  • 86
  • That project looks great, but it doesn't appear to have a `ConcurrentQueue` implementation. Looks like some nice code though -- I'll definitely have a read of the source. – Drew Noakes Feb 20 '12 at 09:37
  • this is well outdated project which does not include ConcurrentQueue. It looks like it is abandoned since MS release of System.Collections.Concurrent for .net4 So question still open. Is there any good implementation of ConcurrentQueue for SL5? Oppositional, did you succeed with decomplining? – Konstantin Salavatov Mar 03 '12 at 06:08
  • Decompile while theortically possible was more difficult than I originally thought (used BCL classes not available in Silverlight). It might be easier to write collection classes from scratch, but I have not had time to try. – Oppositional Jun 02 '12 at 04:43
  • This has ConcurrentQueue http://robertmclaws.com/nuget-packages/system-threading-tasks-for-silverlight – jonperl Jun 23 '12 at 01:54
  • @Cœur Seems to work for me. Here is a google cache as well http://webcache.googleusercontent.com/search?q=cache:Fk7Ye-zZi88J:https://ch.codeplex.com/+&cd=1&hl=en&ct=clnk&gl=us – jonperl Aug 13 '14 at 22:56
  • @jonperl not the answer link, the comment link to robertmclaws.com. – Cœur Aug 14 '14 at 10:10
2

The class library for Mono includes implementations of the various concurrent collections, and is licensed under the very permissive MIT license.

Sam Harwell
  • 97,721
  • 20
  • 209
  • 280