System::Threading::Thread クラス

Thread class

Thread implementation. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

class Thread : public System::Object

メソッド

メソッド説明
Abort()スレッドを中止します。実装されていません。
get_CurrentCulture()スレッドのカルチャを取得します。
static get_CurrentThread()現在のスレッドを記述するオブジェクトを取得します。
get_CurrentUICulture()スレッドで使用されるユーザーインターフェイスのカルチャを取得します。
get_IsAlive()スレッドが存続しているかどうかを確認します。
get_IsBackground()スレッドがバックグラウンドかどうかを確認します。
get_IsThreadPoolThread()スレッドがスレッドプールに所属しているかどうかを確認します。
get_ManagedThreadId() constスレッドの識別子を取得します。OS から取得可能ですが、OS のスレッド識別子が int の上限を超える場合、スレッドの ID が衝突する可能性があります。
get_Name()スレッド名を取得します。
get_ThreadState()スレッドの状態を取得します。
static GetCurrentThreadId()現在のスレッドの識別子を取得します。
GetHashCode() const override
Interrupt()スレッドを割り込みます。実装されていません。
Join()管理対象スレッドに参加します。必要に応じて無制限の待機を行います。
Join(int)管理対象スレッドに参加します。制限付きの待機を行います。
Join(TimeSpan)管理対象スレッドに参加します。制限付きの待機を行います。
static MemoryBarrier()メモリアクセスを同期します。
operator=(const Thread&)別のスレッドから TLS データをコピーします。
set_CurrentCulture(const SharedPtr<Globalization::CultureInfo>&)スレッドのカルチャを設定します。
set_CurrentUICulture(const SharedPtr<Globalization::CultureInfo>&)スレッドで使用されるユーザーインターフェイスのカルチャを設定します。
set_IsBackground(bool)スレッドをバックグラウンドまたはフォアグラウンドに設定します。
set_Name(const System::String&)スレッド名を設定します。
static Sleep(int)指定されたタイムアウトで現在のスレッドを停止します。
static Sleep(TimeSpan)指定されたタイムアウトで現在のスレッドを停止します。
static SpinWait(int)特定のループ反復回数を待機します。
Start()null 引数オブジェクトを使用してスレッドを開始します。
Start(const System::SharedPtr<System::Object>&)スレッドを開始します。
Thread()コンストラクタ。
Thread(ThreadStart)コンストラクタ。
Thread(ParameterizedThreadStart)コンストラクタ。
Thread(Thread&)コピーコンストラクタ。
static Yield()スレッドを譲渡します。
virtual ~Thread()デストラクタ。

備考

#include "system/threading/thread.h"
#include "system/smart_ptr.h"

int main()
{
  auto thread = System::MakeObject<System::Threading::Thread>([]()
  {
    std::cout << "Child thread ID: " << System::Threading::Thread::GetCurrentThreadId() << std::endl;
    System::Threading::Thread::Sleep(200);
  });

  std::cout << "Main thread ID: " << System::Threading::Thread::GetCurrentThreadId() << std::endl;

  thread->Start();
  thread->Join();

  return 0;
}
/*
This code example produces the following output:
Main thread ID: 2
Child thread ID: 1
*/

参照