Threading Library for Multithreaded Windows Service [closed]

☆樱花仙子☆ 提交于 2019-12-10 13:41:21

问题


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.

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.

Any suggestions?


回答1:


Consider this project http://www.codeplex.com/smartthreadpool

Project Description

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:

  • 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.



回答2:


This is a bit tongue in cheek, but how about the .NET Framework? The System.Threading namespace has everything you need for this.

If you can use .NET 4, or the backport in the Rx Framework, the Task Parallel Library may make some of this a bit easier, as well, but even without that, the standard framework has everything you'd need.




回答3:


If you need a scheduling library that has multi-threading support, I've used this before: Quartz.NET

http://quartznet.sourceforge.net/



来源:https://stackoverflow.com/questions/2015768/threading-library-for-multithreaded-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!