Click or drag to resize

WorkerThreadPool Class

A thread pool that manages work items, in contrast to the common .net threadpool, threads managed by this pool may perform calls to COM objects.
Inheritance Hierarchy
SystemObject
  Jam.ShellWorkerThreadPool

Namespace: Jam.Shell
Assembly: ShellBrowser.Core (in ShellBrowser.Core.dll) Version: 7.2
Syntax
public class WorkerThreadPool : IDisposable

The WorkerThreadPool type exposes the following members.

Constructors
 NameDescription
Public methodWorkerThreadPool Standard constructor, initializes a threadpool without support for COM.
Public methodWorkerThreadPool(Boolean) Creates a new WorkerThreadPool instance.
Public methodWorkerThreadPool(Boolean, Boolean) Creates a new WorkerThreadPool instance.
Top
Properties
 NameDescription
Public propertyStatic memberInstance Get a lazy initialized singleton instance of WorkerThreadPool (thread-safe). Per default the Threadpool is prepared for usage with COM, see InstanceInitializesCOM.
Public propertyStatic memberInstanceInitializesCOM Whether the threadpool returned by Instance initializes to let the threads in the pool make use of COM objects. The default value is true.
Public propertyStatic memberInstanceUsesLIFO Whether the threadpool returned by Instance uses LIFO, the default value is false
Public propertyMaxBusyTime The maximum time a thread may be busy until it is aborted.
Public propertyMaxCpuUsage The maximum cpu usage in percent were spawning additional worker threads is allowed
Public propertyMaxIdleTime The maximum time a thread may be idle until it is removed from the pool if more that MinWorkerThreads are available
Public propertyMaxTimeUntilHardTerminate Gets or sets the maximum time threads are given to finish when the ThreadPool is terminated before they are aborted.
Public propertyMaxWorkerThreads The maximum number of worker threads the pool may allocate
Public propertyMinWorkerThreads The minimum number of worker threads
Protected propertyPaused If this property is set to true the processing of new work items is paused, if it is set to false, processing is resumed. Getter and setter of this method are thread safe.
Public propertyQueryCpuUsage If this property is set to true, the threadpool queries the current overall cpu load to determine whether to start additional threads that process the work items. . The default value for this setting is true.
Public propertyQueueLength Returns the number of work items residing in the queue waiting to get processed by the next free thread.
Public propertyTerminated Returns true if processing was terminated via TerminateProcessing or TerminateProcessing(Boolean). Is reset to false in a call to StartProcessing.
Public propertyUseLIFO If set to False, the oldest work item in the queue will be used a next item. This is the default value. If set to True, the newest work item in the queue will be used as next work item. True can be a good setting if the number of work items is large and their order doesn't matter
Public propertyWorkItemsCount Returns the number of current work items.
Top
Methods
 NameDescription
Public methodAbortThreadsExceedingMaxBusyTime This method removes threads from the busy pool if the maximum busy time is exceeded. Additionally if the thread is being stopped, if it doesn't join within 100ms abort is signalled via Abort.
Public methodAddWorkItem(IWorkItem) Adds a work item to the internal queue but and immediately starts processing the item, see also AddWorkItem(IWorkItem, Boolean) and StartProcessing.
Public methodAddWorkItem(IWorkItem, Boolean) Adds a work item to the internal queue but does not yet start processing them, see StartProcessing for that.
Protected methodCheckAddNewWorkerThread Determines whether new threads should be spawned, ensures that MinWorkerThreads threads are available for processing
Protected methodCheckDisposed Call this method to check if the thread pool is still available.
Public methodDispose Call this method to clean up all threads from the pool, in that case the ThreadPool instance cannot be used anymore, calls to functions of it will result in an ObjectDisposedException.
Protected methodDispose(Boolean) Implementation of IDispsable interface
Public methodStatic memberGetCpuUsage Determines the overall cpu usage of the current process
Protected methodOnApplicationExit Stops any pending threads if the applications exits
Public methodQueueGUIWorkItem Adds a work item to the Threadpool that is immediately being processed. When the WorkItem is finished Event OnCompleted is raised on the calling synchronization context, so that no BeginInvoke is needed to update the main thread.
Public methodQueueUserWorkItem(WaitCallback) Adds a user work item to the Threadpool that is immediately being processed.
Public methodQueueUserWorkItem(WaitCallback, Object) Adds a user work item to the Threadpool that is immediately being processed.
Public methodQueueUserWorkItem(WaitCallback, Object, Int32) Adds a user work item to the Threadpool that is immediately being processed and tagged with the given handle.
Public methodQueueUserWorkItem(WaitCallback, Object, Int32, Int32) Adds a user work item to the Threadpool that is processed after the given time and tagged with the given handle.
Public methodQueueUserWorkItemT(ActionT) Adds an ActionT delegate call to the work item queue.
Public methodQueueUserWorkItemT(ActionT, T) Adds an ActionT delegate call to the work item queue.
Public methodQueueUserWorkItemT(ActionT, T, String) Adds an ActionT delegate call to the work item queue.
Public methodRemoveThreadsExceedingMaxIdleTime This method removes threads from the idle pool where the maximum idle time is exceeded. This method does nothing if only MinWorkerThreads are active
Public methodStartProcessing Start processing the work items (AddWorkItem(IWorkItem, Boolean))
Public methodTerminateProcessing Stops processing work items that are queued. Running threads will be aborted after MaxTimeUntilHardTerminate ms.
Public methodTerminateProcessing(Boolean) Stops processing work items that are queued.
Public methodTerminateProcessing(Int32) Stops processing the threads.
Public methodTerminateWorkItemsForTag Removes all pending work items from the work queue and terminates the running work items having the tag specified.
Public methodTerminateWorkItemsForType Removes all pending work items of type 'type'.
Public methodToStringReturns a string that represents the current object.
(Overrides ObjectToString)
Public methodToString(Boolean)Returns the list of WorkItems in the Queue and that are being processed at the moment. Note that the NameTag has to be set when queueing the items with QueueUserWorkItem.
Public methodWaitFinish Waits until all threads finished processing (the workitem queue is empty).
Public methodWaitFinish(Int32) Waits until all threads finished processing (the workitem queue is empty).
Top
Events
 NameDescription
Public eventAllWorkItemsDone This event occurs if the threads finished processing all workitems, it happens from a different thread context. So do not perform gui operations directly.
Public eventNewWorkItemEvent This event occurs if a new work item begins to process
Top
See Also