diff --git a/SmartThreadPool/STPStartInfo.cs b/SmartThreadPool/STPStartInfo.cs index fdab702..d19a1d9 100644 --- a/SmartThreadPool/STPStartInfo.cs +++ b/SmartThreadPool/STPStartInfo.cs @@ -15,6 +15,7 @@ namespace Amib.Threading private string _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName; private bool _areThreadsBackground = SmartThreadPool.DefaultAreThreadsBackground; private bool _enableLocalPerformanceCounters; + private string _threadPoolName = SmartThreadPool.DefaultThreadPoolName; public STPStartInfo() { @@ -34,6 +35,7 @@ namespace Amib.Threading _threadPriority = stpStartInfo.ThreadPriority; _performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName; _enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters; + _threadPoolName = stpStartInfo._threadPoolName; _areThreadsBackground = stpStartInfo.AreThreadsBackground; } @@ -95,6 +97,18 @@ namespace Amib.Threading } } + /// + /// Get/Set the thread pool name. Threads will get names depending on this. + /// + public virtual string ThreadPoolName { + get { return _threadPoolName; } + set + { + ThrowIfReadOnly (); + _threadPoolName = value; + } + } + /// /// Get/Set the performance counter instance name of this SmartThreadPool /// The default is null which indicate not to use performance counters at all. diff --git a/SmartThreadPool/SmartThreadPool.cs b/SmartThreadPool/SmartThreadPool.cs index 9853d72..0801254 100644 --- a/SmartThreadPool/SmartThreadPool.cs +++ b/SmartThreadPool/SmartThreadPool.cs @@ -161,6 +161,11 @@ namespace Amib.Threading /// /// The default fill state with params. (false) + + /// + /// The default thread pool name. (SmartThreadPool) + /// + public const string DefaultThreadPoolName = "SmartThreadPool"; /// It is relevant only to QueueWorkItem of Action<...>/Func<...> /// public const bool DefaultFillStateWithArgs = false; @@ -395,7 +400,7 @@ namespace Amib.Threading private void Initialize() { - Name = "SmartThreadPool"; + Name = _stpStartInfo.ThreadPoolName; ValidateSTPStartInfo(); // _stpStartInfoRW stores a read/write copy of the STPStartInfo.