diff --git a/SmartThreadPool/STPStartInfo.cs b/SmartThreadPool/STPStartInfo.cs
index c4a8e07..fdab702 100644
--- a/SmartThreadPool/STPStartInfo.cs
+++ b/SmartThreadPool/STPStartInfo.cs
@@ -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
}
}
+ ///
+ /// Get/Set backgroundness of thread in thread pool.
+ ///
+ public virtual bool AreThreadsBackground
+ {
+ get { return _areThreadsBackground; }
+ set
+ {
+ ThrowIfReadOnly ();
+ _areThreadsBackground = value;
+ }
+ }
+
///
/// Get a readonly version of this STPStartInfo.
///
diff --git a/SmartThreadPool/SmartThreadPool.cs b/SmartThreadPool/SmartThreadPool.cs
index 2b0202f..9853d72 100644
--- a/SmartThreadPool/SmartThreadPool.cs
+++ b/SmartThreadPool/SmartThreadPool.cs
@@ -164,6 +164,11 @@ namespace Amib.Threading
/// It is relevant only to QueueWorkItem of Action<...>/Func<...>
///
public const bool DefaultFillStateWithArgs = false;
+
+ ///
+ /// The default thread backgroundness. (true)
+ ///
+ 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