CHG: STP threads can now be foreground

(cherry picked from commit b29bd9578aa4b9ec6b84137ae5ab00d0a410c8e0)
This commit is contained in:
Michal Staszewski
2011-06-21 14:15:17 +02:00
committed by Piotr Wysocki
parent 5d0199356f
commit 17f4f59706
2 changed files with 21 additions and 1 deletions
+15
View File
@@ -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>
+6 -1
View File
@@ -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