Wiki Navigation
- Loading...
The ThreadPool class controls the threadpool, keeps track of unused/idle threads and starts new threads if the current pool becomes exhausted and hasn't reached its upper limit yet. The ThreadPool class implements the IThreadPool interface. The threadpool is registered as a global service with the GlobalServiceProvider through that interface. The ThreadPool can be configured during initialisation of the pool. This is done during the initialisation process of MediaPortal in the class MPApplication in the Run() method. MediaPortal initialises the threadpool with its default configuration. The minimum and maximum number of threads in the threadpool can be specified in a special Constructor. A more advanced configuration is possible through by creating a custom ThreadPoolStartInfo object and passing that configuration through the Constructor during initialisation. The threadpool has a flexible way of logging configuration. It is decoupled from MediaPortal's own Logging service and uses delegates to expose its internal logging messages.
Constructors
- ThreadPool() - Initialises the threadpool with the default configuration
- ThreadPool(int, int) - Initialises the threadpool with min/max number of threads in the pool
- ThreadPool(ThreadPoolStartInfo) - Initialises the threadpool with a more advanced configuration
IThreadPool implementation
The ThreadPool implements all methods and properties of the IThreadPool interface. See the IThreadPool documentation for more information about the methods and properties exposed by this interface.
Logging facility
- LoggerDelegate InfoLog - Register with this delegate to receive informational log messages from the threadpool
- LoggerDelegate WarnLog - Register with this delegate to receive warning log messages from the threadpool
- LoggerDelegate ErrorLog - Register with this delegate to receive error log messages from the threadpool
- LoggerDelegate DebugLog - Register with this delegate to receive debug log messages from the threadpool
Initialisation
Default initialisation
IThreadPool itp = new ThreadPool();
Specifying min/max number of threads during creation
IThreadPool itp = new ThreadPool(5, 30);
More advanced example
ThreadPoolStartInfo tpsi = new ThreadPoolStartInfo(); tpsi.Name = "My ThreadPool"; tpsi.MinimumThreads = 10; tpsi.MaximumThreads = 50; tpsi.ThreadIdleTimeout = 30000; tpsi.DelayedInit = false; tpsi.DefaultThreadPriority = ThreadPriority.BelowNormal; IThreadPool itp = new ThreadPool(tpsi);

This page has no comments.