mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-28 23:01:25 +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 int _maxWorkerThreads = SmartThreadPool.DefaultMaxWorkerThreads;
|
||||||
private ThreadPriority _threadPriority = SmartThreadPool.DefaultThreadPriority;
|
private ThreadPriority _threadPriority = SmartThreadPool.DefaultThreadPriority;
|
||||||
private string _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName;
|
private string _performanceCounterInstanceName = SmartThreadPool.DefaultPerformanceCounterInstanceName;
|
||||||
|
private bool _areThreadsBackground = SmartThreadPool.DefaultAreThreadsBackground;
|
||||||
private bool _enableLocalPerformanceCounters;
|
private bool _enableLocalPerformanceCounters;
|
||||||
|
|
||||||
public STPStartInfo()
|
public STPStartInfo()
|
||||||
@@ -33,6 +34,7 @@ namespace Amib.Threading
|
|||||||
_threadPriority = stpStartInfo.ThreadPriority;
|
_threadPriority = stpStartInfo.ThreadPriority;
|
||||||
_performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName;
|
_performanceCounterInstanceName = stpStartInfo.PerformanceCounterInstanceName;
|
||||||
_enableLocalPerformanceCounters = stpStartInfo._enableLocalPerformanceCounters;
|
_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>
|
/// <summary>
|
||||||
/// Get a readonly version of this STPStartInfo.
|
/// Get a readonly version of this STPStartInfo.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -164,6 +164,11 @@ namespace Amib.Threading
|
|||||||
/// It is relevant only to QueueWorkItem of Action<...>/Func<...>
|
/// It is relevant only to QueueWorkItem of Action<...>/Func<...>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const bool DefaultFillStateWithArgs = false;
|
public const bool DefaultFillStateWithArgs = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The default thread backgroundness. (true)
|
||||||
|
/// </summary>
|
||||||
|
public const bool DefaultAreThreadsBackground = true;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -608,7 +613,7 @@ namespace Amib.Threading
|
|||||||
|
|
||||||
// Configure the new thread and start it
|
// Configure the new thread and start it
|
||||||
workerThread.Name = "STP " + Name + " Thread #" + _threadCounter;
|
workerThread.Name = "STP " + Name + " Thread #" + _threadCounter;
|
||||||
workerThread.IsBackground = true;
|
workerThread.IsBackground = _stpStartInfo.AreThreadsBackground;
|
||||||
#if !(_SILVERLIGHT)
|
#if !(_SILVERLIGHT)
|
||||||
workerThread.Priority = _stpStartInfo.ThreadPriority;
|
workerThread.Priority = _stpStartInfo.ThreadPriority;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user