mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 09:01:19 +03:00
CHG: STP threads can now be foreground
(cherry picked from commit b29bd9578aa4b9ec6b84137ae5ab00d0a410c8e0)
This commit is contained in:
committed by
Piotr Wysocki
parent
5d0199356f
commit
17f4f59706
@@ -13,6 +13,7 @@ namespace Amib.Threading
|
||||
private int _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads;
|
||||
private ThreadPriority _threadPriority = SmartThreadPool.DefaultThreadPriority;
|
||||
private string _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName;
|
||||
private bool _areThreadsBackground = SmartThreadPool.DefaultAreThreadsBackground;
|
||||
private bool _enableLocalPerformanceCounters;
|
||||
|
||||
public STPStartInfo()
|
||||
@@ -33,6 +34,7 @@ namespace Amib.Threading
|
||||
_threadPriority = stpStartInfo.ThreadPriority;
|
||||
_performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName;
|
||||
_enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters;
|
||||
_areThreadsBackground = stpStartInfo.AreThreadsBackground;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,6 +125,19 @@ namespace Amib.Threading
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get/Set backgroundness of thread in thread pool.
|
||||
/// </summary>
|
||||
public virtual bool AreThreadsBackground
|
||||
{
|
||||
get { return _areThreadsBackground; }
|
||||
set
|
||||
{
|
||||
ThrowIfReadOnly ();
|
||||
_areThreadsBackground = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a readonly version of this STPStartInfo.
|
||||
/// </summary>
|
||||
|
||||
@@ -164,6 +164,11 @@ namespace Amib.Threading
|
||||
/// It is relevant only to QueueWorkItem of Action<...>/Func<...>
|
||||
/// </summary>
|
||||
public const bool DefaultFillStateWithArgs = false;
|
||||
|
||||
/// <summary>
|
||||
/// The default thread backgroundness. (true)
|
||||
/// </summary>
|
||||
public const bool DefaultAreThreadsBackground = true;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -608,7 +613,7 @@ namespace Amib.Threading
|
||||
|
||||
// Configure the new thread and start it
|
||||
workerThread.Name = "STP " + Name + " Thread #" + _threadCounter;
|
||||
workerThread.IsBackground = true;
|
||||
workerThread.IsBackground = _stpStartInfo.AreThreadsBackground;
|
||||
#if !(_SILVERLIGHT)
|
||||
workerThread.Priority = _stpStartInfo.ThreadPriority;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user