Thread.GetDomainID Metodo
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Restituisce un identificatore univoco del dominio dell'applicazione.
public:
static int GetDomainID();
public static int GetDomainID();
static member GetDomainID : unit -> int
Public Shared Function GetDomainID () As Integer
Valori restituiti
Intero con segno a 32 bit che identifica in modo univoco il dominio applicazione.
Esempio
Nell'esempio di codice seguente viene illustrato come recuperare il nome e l'ID dell'oggetto AppDomain in cui è in esecuzione il thread.
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