Versión imprimible       Enviar     
Evaluar y enviar comentarios
Contraer todo/Expandir todo Contraer todo
Esta página es específica de
Microsoft Visual Studio 2005/.NET Framework 2.0

Hay además otras versiones disponibles para:
Thread.GetDomain (Método)
Devuelve el dominio actual en el que se está ejecutando el subproceso actual.

Espacio de nombres: System.Threading
Ensamblado: mscorlib (en mscorlib.dll)

Visual Basic (Declaración)
Public Shared Function GetDomain As AppDomain
Visual Basic (Uso)
Dim returnValue As AppDomain

returnValue = Thread.GetDomain
C#
public static AppDomain GetDomain ()
C++
public:
static AppDomain^ GetDomain ()
J#
public static AppDomain GetDomain ()
JScript
public static function GetDomain () : AppDomain
XAML
No aplicable.

Valor devuelto

AppDomain que representa el dominio de la aplicación actual del subproceso en ejecución.

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.

Visual Basic
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
C#
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());
    }
}
C++
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();
}
J#
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

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.

.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
© 2009 Microsoft Corporation. Reservados todos los derechos. Términos de uso | Marcas Registradas | Privacidad
Page view tracker