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

Thread.Name プロパティ

スレッドの名前を取得または設定します

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

例外例外
例外種類条件

InvalidOperationException

設定操作要求されましたが、Name プロパティは既に設定されています。

解説解説

このプロパティは、一度だけ書き込むことができます

使用例使用例

スレッドに名前を付け方法の例を次に示します

Imports System
Imports System.Threading

Public Class Name

    <MTAThread> _
    Shared Sub Main()

        ' Check whether the thread has previously been named
        ' to avoid a possible InvalidOperationException.
        If Thread.CurrentThread.Name = Nothing
 Then
            Thread.CurrentThread.Name = "MainThread"
        Else
            Console.WriteLine("Unable to name a previously "
 & _
                "named thread.")
        End If

    End Sub
End Class
using System;
using System.Threading;

class Name
{
    static void Main()
    {
        // Check whether the thread has previously been named
        // to avoid a possible InvalidOperationException.
        if(Thread.CurrentThread.Name == null)
        {
            Thread.CurrentThread.Name = "MainThread";
        }
        else
        {
            Console.WriteLine("Unable to name a previously " +
                "named thread.");
        }
    }
}
using namespace System;
using namespace System::Threading;
int main()
{
   
   // Check whether the thread has previously been named to
   // avoid a possible InvalidOperationException.
   if ( Thread::CurrentThread->Name == nullptr )
   {
      Thread::CurrentThread->Name =  "MainThread";
   }
   else
   {
      Console::WriteLine( "Unable to name a previously "
      "named thread." );
   }
}

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

class Name
{
    public static void main(String[]
 args)
    {
        // Check whether the thread has previously been named
        // to avoid a possible InvalidOperationException.
        if (Thread.get_CurrentThread().get_Name() == null)
 {
            Thread.get_CurrentThread().set_Name("MainThread");
        }
        else {
            Console.WriteLine(("Unable to name a previously " 
                + "named thread."));
        } 
    } //main
} //Name
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



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

辞書ショートカット

すべての辞書の索引

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

   

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



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

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

©2025 GRAS Group, Inc.RSS