Thread::GetDomain Method ()

 

Returns the current domain in which the current thread is running.

Namespace:   System.Threading
Assembly:  mscorlib (in mscorlib.dll)

public:
static AppDomain^ GetDomain()

Return Value

Type: System::AppDomain^

An AppDomain representing the current application domain of the running thread.

The following code example shows how to retrieve the name and ID of the AppDomain in which the thread is running.

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();
}

.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: