Devuelve el dominio actual en el que se está ejecutando el subproceso actual.
Espacio de nombres: System.Threading
Ensamblado: mscorlib (en mscorlib.dll)

Sintaxis
Visual Basic (Declaración)
Public Shared Function GetDomain As AppDomain
Dim returnValue As AppDomain
returnValue = Thread.GetDomain
public static AppDomain GetDomain ()
public:
static AppDomain^ GetDomain ()
public static AppDomain GetDomain ()
public static function GetDomain () : AppDomain
Valor devuelto
AppDomain que representa el dominio de la aplicación actual del subproceso en ejecución.

Ejemplo
En el ejemplo de código siguiente se muestra la forma de recuperar el nombre y el identificador del AppDomain en que se ejecuta el subproceso.
Imports System
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
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());
}
}
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();
}
import System.*;
import System.Threading.*;
import System.Threading.Thread;
class Test
{
public static void main(String[] args)
{
Thread newThread = new Thread(new ThreadStart(ThreadMethod));
newThread.Start();
} //main
static void ThreadMethod()
{
Console.WriteLine("Thread {0} started in {1} with AppDomainID = {2}.",
String.valueOf(AppDomain.GetCurrentThreadId()),
Thread.GetDomain().get_FriendlyName(),
String.valueOf(Thread.GetDomainID()));
} //ThreadMethod
} //Test

Plataformas
Windows 98, Windows 2000 Service Pack 4, Windows CE, Windows Millennium, Windows Mobile para Pocket PC, Windows Mobile para Smartphone, Windows Server 2003, Windows XP Media Center, Windows XP Professional x64, Windows XP SP2, Windows XP Starter
Microsoft .NET Framework 3.0 es compatible con Windows Vista, Microsoft Windows XP SP2 y Windows Server 2003 SP1.

Información de versión
.NET Framework
Compatible con: 3.0, 2.0, 1.1, 1.0
.NET Compact Framework
Compatible con: 2.0
XNA Framework
Compatible con: 1.0

Vea también