Thread.IsThreadPoolThread プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Thread.IsThreadPoolThread プロパティの意味・解説 

Thread.IsThreadPoolThread プロパティ

スレッドマネージ スレッド プール所属しているかどうかを示す値を取得します

名前空間: System.Threading
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As Thread
Dim value As Boolean

value = instance.IsThreadPoolThread
public bool IsThreadPoolThread { get;
 }
public:
property bool IsThreadPoolThread {
    bool get ();
}
/** @property */
public boolean get_IsThreadPoolThread ()
public function get IsThreadPoolThread
 () : boolean

プロパティ
このスレッドマネージ スレッド プール所属している場合trueそれ以外場合false

使用例使用例

スレッドスレッド プール属するものであるかどうか判断する方法の例を次に示します

Option Explicit
Option Strict

Imports System
Imports System.Threading

Public Class IsThreadPool

    <MTAThread> _
    Shared Sub Main()
        Dim autoEvent As New
 AutoResetEvent(False)

        Dim regularThread As New
 Thread(AddressOf ThreadMethod)
        regularThread.Start()
        ThreadPool.QueueUserWorkItem(AddressOf WorkMethod, autoEvent)

        ' Wait for foreground thread to end.
        regularThread.Join()

        ' Wait for background thread to end.
        autoEvent.WaitOne()
    End Sub

    Shared Sub ThreadMethod()
        Console.WriteLine("ThreadOne, executing ThreadMethod,
 " & _
            "is from the thread pool? {0}", _
            Thread.CurrentThread.IsThreadPoolThread)
    End Sub

    Shared Sub WorkMethod(stateInfo As
 Object)
        Console.WriteLine("ThreadTwo, executing WorkMethod, "
 & _
            "is from the thread pool? {0}", _
            Thread.CurrentThread.IsThreadPoolThread)

        ' Signal that this thread is finished.
        DirectCast(stateInfo, AutoResetEvent).Set()
    End Sub

End Class
using System;
using System.Threading;

class IsThreadPool
{
    static void Main()
    {
        AutoResetEvent autoEvent = new AutoResetEvent(false);

        Thread regularThread = 
            new Thread(new ThreadStart(ThreadMethod));
        regularThread.Start();
        ThreadPool.QueueUserWorkItem(new WaitCallback(WorkMethod),
 
            autoEvent);

        // Wait for foreground thread to end.
        regularThread.Join();

        // Wait for background thread to end.
        autoEvent.WaitOne();
    }

    static void ThreadMethod()
    {
        Console.WriteLine("ThreadOne, executing ThreadMethod, " +
            "is {0}from the thread pool.", 
            Thread.CurrentThread.IsThreadPoolThread ? "" : "not ");
    }

    static void WorkMethod(object stateInfo)
    {
        Console.WriteLine("ThreadTwo, executing WorkMethod, " +
            "is {0}from the thread pool.", 
            Thread.CurrentThread.IsThreadPoolThread ? "" : "not ");

        // Signal that this thread is finished.
        ((AutoResetEvent)stateInfo).Set();
    }
}
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();
}

import System.*;
import System.Threading.*;
import System.Threading.Thread;

class IsThreadPool
{
    public static void main(String[]
 args)
    {
        AutoResetEvent autoEvent = new AutoResetEvent(false);
        Thread regularThread = new Thread(new
 ThreadStart(ThreadMethod));

        regularThread.Start();
        ThreadPool.QueueUserWorkItem(new WaitCallback(WorkMethod),
 autoEvent);

        // Wait for foreground thread to end.
        regularThread.Join();

        // Wait for background thread to end.
        autoEvent.WaitOne();
    } //main

    static void ThreadMethod()
    {
        Console.WriteLine("ThreadOne, executing ThreadMethod, " 
            +  "is {0}from the thread pool.", 
            (Thread.get_CurrentThread().get_IsThreadPoolThread())
            ? "" : "not ");
    } //ThreadMethod

    static void WorkMethod(Object stateInfo)
    {
        Console.WriteLine("ThreadTwo, executing WorkMethod, " + 
            "is {0}from the thread pool.",
            (Thread.get_CurrentThread().get_IsThreadPoolThread()) 
            ? "" : "not ");

        // Signal that this thread is finished.
        ((AutoResetEvent)(stateInfo)).Set();
    } //WorkMethod
} //IsThreadPool
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からThread.IsThreadPoolThread プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からThread.IsThreadPoolThread プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からThread.IsThreadPoolThread プロパティ を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

Thread.IsThreadPoolThread プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Thread.IsThreadPoolThread プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS