Thread.GetDomain Método
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Devolve o domínio atual onde o thread atual está a correr.
public:
static AppDomain ^ GetDomain();
public static AppDomain GetDomain();
static member GetDomain : unit -> AppDomain
Public Shared Function GetDomain () As AppDomain
Devoluções
Um AppDomain representa o domínio de aplicação atual da thread em execução.
Exemplos
O exemplo de código seguinte mostra como recuperar o nome e o ID da AppDomain thread em que o thread está a correr.
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());
}
}
open System
open System.Threading
let threadMethod () =
printfn $"Thread {AppDomain.GetCurrentThreadId()} started in {Thread.GetDomain().FriendlyName} with AppDomainID = {Thread.GetDomainID()}."
let newThread = Thread threadMethod
newThread.Start()
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