Silverlight 4 中有哪些线程安全集合类可用?
我正在开发一个应用程序框架,客户端将使用 Silverlight,服务器端将使用 .NET 4。在内部,该框架具有字典和队列数据结构,其中多个线程将同时访问集合。
在服务器端,我想利用 ConcurrentDictionary 和 < a href="http://msdn.microsoft.com/en-us/library/dd267265.aspx" rel="nofollow noreferrer">ConcurrentQueue 类可在System.Collections.Concurrent 命名空间。然而,这些类并未在 Silverlight 4 中实现。
我正在考虑的两种方法是:
- 反编译 ConcurrentDictionary 和 ConcurrentQueue 类和 在 Silverlight 中实现它们 类库。这些将使用 System.Collections.Concurrent 命名空间来确定范围。
- 实现自定义线程安全 我需要在共享中收集类 图书馆(或找到一个可靠的 Silverlight 线程安全集合 实现),可以在服务器端和客户端使用。
第一种方法允许我只实现我需要的 Silverlight 数据结构,但我担心在我的 Silverlight 实现和 .NET 4 中实现的并发集合类之间引入差异。
第二种方法将在客户端和客户端上提供一致的并发集合实现 。和服务器端,但感觉我会重新发明轮子。
似乎没有实现 ConcurrentDictionary 和 ConcurrentQueue Silverlight 中的类将非常有用很难,但是 Silverlight 是否已经有一个被广泛采用的线程安全集合类库?
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:
- Decompile the ConcurrentDictionary
and ConcurrentQueue classes and
implement them in a Silverlight
class library. These would be scoped using the System.Collections.Concurrent namespace. - 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个:http://ch.codeplex.com/
Try this out: http://ch.codeplex.com/
Mono 的类库包含各种并发集合的实现,并根据非常宽松的 MIT 许可证获得许可。
The class library for Mono includes implementations of the various concurrent collections, and is licensed under the very permissive MIT license.