Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Threading Library for Multithreaded Windows Service [closed]

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?

like image 252
anon2009 Avatar asked Jan 06 '10 19:01

anon2009


2 Answers

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.

like image 72
Reed Copsey Avatar answered Nov 01 '22 17:11

Reed Copsey


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.
like image 44
Fahad Avatar answered Nov 01 '22 16:11

Fahad