分享一个用C#(.NET)实现的多功能线程池管理组件--Smart Thread Pool

类库组件 2014-08-20 29968浏览 收藏本文

今天在Codeproject上发现一个关于线程和线程池的好东东--Smart Thread Pool,在此与大家一起分享。 smartthreadpool 这个组件实现了很多关于线程的高级功能,并且作者Ami Bar提供了实现的源码,实例,测试以及Demo。Smart Thread Pool的主要功能如下(原文,翻译过来感觉怪怪的):

  • 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 if it hasn't been executed yet.
  • 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.
  • A 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.
  • Threads have initialization and termination events.
  • WinCE platform is supported (limited).
  • Action<T> and Func<T> generic methods are supported.
  • Silverlight is supported.
  • Mono is supported.
  • Performance counters (Windows and internal).
  • Work item timeout (passive).
  • Threads ApartmentState
  • Threads IsBakcground
  • Threads name template
  • Windows Phone is supported (limited)
  • Threads MaxStackSize
相信看完这个实例后,你会对线程的相关知识有个新的认识。

转载请注明:图享网 » 分享一个用C#(.NET)实现的多功能线程池管理组件--Smart Thread Pool

验证码