Thread.GetDomain 方法  
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
返回当前线程正在其中运行的当前域。
public:
 static AppDomain ^ GetDomain();public static AppDomain GetDomain ();static member GetDomain : unit -> AppDomainPublic Shared Function GetDomain () As AppDomain返回
表示正在运行的线程的当前应用程序域的 AppDomain。
示例
下面的代码示例演示如何检索运行线程的 的名称和 AppDomain ID。
using namespace System;
using namespace System::Threading;
ref class Test
{
private:
   Test(){}
public:
   static void ThreadMethod()
   {
      Console::WriteLine( "Thread {0} started in {1} with AppDomainID = {2}.", AppDomain::GetCurrentThreadId().ToString(), Thread::GetDomain()->FriendlyName, Thread::GetDomainID().ToString() );
   }
};
int main()
{
   Thread^ newThread = gcnew Thread( gcnew ThreadStart( &Test::ThreadMethod ) );
   newThread->Start();
}
using System;
using System.Threading;
class Test
{
    static void Main()
    {
        Thread newThread = new Thread(new ThreadStart(ThreadMethod));
        newThread.Start();
    }
    static void ThreadMethod()
    {
        Console.WriteLine(
            "Thread {0} started in {1} with AppDomainID = {2}.",
            AppDomain.GetCurrentThreadId().ToString(), 
            Thread.GetDomain().FriendlyName, 
            Thread.GetDomainID().ToString());
    }
}
Imports System.Threading
Public Class Test
    <MTAThread> _
    Shared Sub Main()
        Dim newThread As New Thread(AddressOf ThreadMethod)
        newThread.Start()
    End Sub
    Shared Sub ThreadMethod()
        Console.WriteLine( _
            "Thread {0} started in {1} with AppDomainID = {2}.", _
            AppDomain.GetCurrentThreadId().ToString(), _
            Thread.GetDomain().FriendlyName, _
            Thread.GetDomainID().ToString())
    End Sub
End Class