Thread::IsThreadPoolThread Property
.NET Framework (current version)
Gets a value indicating whether or not a thread belongs to the managed thread pool.
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System::Booleantrue if this thread belongs to the managed thread pool; otherwise, false.
For more information see The Managed Thread Pool.
The following code example shows how to determine whether a thread is from the thread pool.
using namespace System; using namespace System::Threading; ref class IsThreadPool { public: static void ThreadMethod() { Console::WriteLine( "ThreadOne, executing ThreadMethod, " "is {0}from the thread pool.", Thread::CurrentThread->IsThreadPoolThread ? (String^)"" : "not " ); } static void WorkMethod( Object^ stateInfo ) { Console::WriteLine( "ThreadTwo, executing WorkMethod, " "is {0}from the thread pool.", Thread::CurrentThread->IsThreadPoolThread ? (String^)"" : "not " ); // Signal that this thread is finished. dynamic_cast<AutoResetEvent^>(stateInfo)->Set(); } }; int main() { AutoResetEvent^ autoEvent = gcnew AutoResetEvent( false ); Thread^ regularThread = gcnew Thread( gcnew ThreadStart( &IsThreadPool::ThreadMethod ) ); regularThread->Start(); ThreadPool::QueueUserWorkItem( gcnew WaitCallback( &IsThreadPool::WorkMethod ), autoEvent ); // Wait for foreground thread to end. regularThread->Join(); // Wait for background thread to end. autoEvent->WaitOne(); }
.NET Framework
Available since 1.1
Available since 1.1
Show: