本文介绍了线程库为多线程Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在寻找一个好的图书馆,最好是在C#中,我可以在Windows服务中使用,它会处理所有的多线程功能所需。
I'm looking for a good library, preferably in C#, which I can use in a windows service and it will handle all the multithreading functionality needed.
该服务将运行每x分钟,检查数据库的过程调用,并为他们每个人产生一个线程并运行它。
The service will run every x minutes, check a database for processes to call, and for each of them spawn a thread and run it.
每个线程应该处理异常,记录和等。
Each thread should handle exceptions, logging and such.
有什么建议?
推荐答案考虑这个项目 www.codeplex / smartthreadpool
项目说明
智能线程池是用C#编写一个线程池。它比.NET内置线程池更先进。 以下为线程池功能的列表:
Smart Thread Pool is a thread pool written in C#. It is far more advanced than the .NET built-in thread pool. Here is a list of the thread pool features:
- 线程的数量动态变化,根据在上的螺纹的工作量池。
- 工作项可以返回一个值。
- 工作项目可以取消。
- 在执行工作项目时,调用程序线程的上下文中使用(有限)。
- 的Win32事件句柄最小数量的使用,所以应用程序的句柄计数不会爆炸。
- 调用者可以等待多个或所有工作项目来完成。
- 工作项目可以有一个PostExecute回调,这将立即叫工作项目已完成。
- 状态对象,随之而来的工作项目,可以自动处理。
- 工作项目例外被送回给调用者。
- 工作项目具有优先权。
- 工作项目组。
- 调用者可以暂停的开始线程池和工作项目组。
- 线程的优先级。
- 可以运行具有单线程公寓的COM对象。
- 支持Action和Func键代表。
- 为WindowsCE的(有限的)支持
- 的MaxThreads和MinThreads可以在运行时改变。
- 取消行为imporved。
- The number of threads dynamically changes according to the workload on the threads in the pool.
- Work items can return a value.
- A work item can be cancelled.
- The caller thread's context is used when the work item is executed (limited).
- Usage of minimum number of Win32 event handles, so the handle count of the application won't explode.
- The caller can wait for multiple or all the work items to complete.
- Work item can have a PostExecute callback, which is called as soon the work item is completed.
- The state object, that accompanies the work item, can be disposed automatically.
- Work item exceptions are sent back to the caller.
- Work items have priority.
- Work items group.
- The caller can suspend the start of a thread pool and work items group.
- Threads have priority.
- Can run COM objects that have single threaded apartment.
- Support Action and Func delegates.
- Support for WindowsCE (limited)
- The MaxThreads and MinThreads can be changed at run time.
- Cancel behavior is imporved.
更多推荐
线程库为多线程Windows服务
发布评论