共用方式為


WebThreadInformation.ThreadID 屬性

定義

取得目前的執行緒識別項。

public:
 property int ThreadID { int get(); };
public int ThreadID { get; }
member this.ThreadID : int
Public ReadOnly Property ThreadID As Integer

屬性值

目前的執行緒識別項。

範例

下列程式碼範例示範如何取得執行緒識別碼。

// Get the task Id.
public string GetThreadId()
{
    // Get the request principal.
    return (string.Format(
        "Thread Id: {0}",
        ThreadInformation.ThreadID.ToString()));
}
' Get the task Id.
Public Function GetThreadId() As String
   ' Get the request principal.
     Return String.Format( _
     "Thread Id: {0}", _
     ThreadInformation.ThreadID.ToString())
End Function 'GetThreadId

備註

即使 Managed 執行緒可能沒有直接對應至 OS 執行緒,為了進行偵錯,請務必隔離可能存在問題的特定執行緒。

適用於