多线程UCMA应用程序导致崩溃.... [英] Multi-Threading an UCMA Application causes Crashes ....

查看:114
本文介绍了多线程UCMA应用程序导致崩溃....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我们已开发出稳定的UCMA(3.0)应用程序,并正在寻找提高性能的方法,因为它已部署到10,000个实际使用环境中用户......

We have developed a stable UCMA (3.0) Application and are looking for ways to improve the performance as it is deployed into a real usage environment with 10,000 of Users ...

我们必须减少应用程序执行时间,因为对于每个用户,它执行创建UserEndPoint,订阅和执行某些处理的任务......

We have to cut down on the Apps execution time as For each User it performs the task of creating a UserEndPoint, Subscribing and doing some processing...

我从.Net 3.5的Microsofts Reactive版本中获取System.Threading.dll并安装它并尝试使用Parallel.ForEach为每个用户并行运行循环

I Got hold of the System.Threading.dll from Microsofts Reactive releases for .Net 3.5 and installed it and tried using the Parallel.ForEach to run the loop in Parallel for each User

但遗憾的是,应用程序运行大约50个用户中途停止和崩溃,我无法调试它。虽然通过在不同的部分引入锁,我能够看到它在UserEndPoint Unsubscribe上死锁,因为它只是挂在那里...使用
Parallel.Foreach 订阅和取消订阅似乎穿越正在运行的线程的电线。

But sadly the application runs for about 50 Users halway through and crashes and I am unable to debug it. Though by introducing locks in the different sections I was able to see it deadlock on UserEndPoint Unsubscribe as it just hangs there... Using the Parallel.Foreach the  Subscribes and UnSubscribes seem to cross wires of the running threads.

有任何的你多使用Parallel.ForEach的类似经历线程UCMA应用程序和我应该做些什么来避免崩溃......

Have any of you a similar experience of Using the Parallel.ForEach in Multi-Threading UCMA Applications and what should I be doing to avoid crashes ...

非常感谢,

Brian

推荐答案

我没有尝试将并行库用于UCMA应用程序,但我使用了线程池线程来处理操作。 基本模式是创建一个封装UserEndpoint的类以及您将对其执行的所有操作。 您
可以在UserEndpoint类的所有实例中共享相同的平台实例。 所以流程是:

I have not tried to use the Parallel library for UCMA apps but I have used thread pool threads to process operations.  The basic pattern is to create a class that encapsulates the UserEndpoint and all the operations that you will do with it.  You can share the same platform instance among all the instances of the UserEndpoint class.  So the flow is:


  • 获取你想要做的工作
  • 创建你的包装类的实例 
  • 通话ThreadPool.QueueUserWorkItem,并通过在活动平台实例和需要所做的工作范围内。

我已经做到了这一点对于我的工作量/操作,每次约200个用户,但你的里程会有所不同。

I've done this for around 200 users at a time for my workload/operations, but your mileage will vary.

如果你想使用.NET 4,那么你可以使用Task做同样的模式。

If you want to use .NET 4, then you can do the same sort of pattern using Task.


这篇关于多线程UCMA应用程序导致崩溃....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆