HOW TO:在 Managed 程式碼中設定執行緒名稱
更新:2007 年 11 月
這個主題適用於:
版本 |
Visual Basic |
C# |
C++ |
Web Developer |
---|---|---|---|---|
Express 版 |
||||
Standard 版 |
||||
Pro/Team 版 |
表格圖例:
套用 |
|
不套用 |
|
預設隱藏的命令。 |
若要在 Managed 程式碼內設定執行緒名稱,請使用 [System.Threading.Thread.Name] 屬性。
範例
Public Class Needle
' This method will be called when the thread is started.
Sub Baz()
Console.WriteLine("Needle Baz is running on another thread")
End Sub
End Class
Sub Main()
Console.WriteLine("Thread Simple Sample")
Dim oNeedle As New Needle()
' Create a Thread object.
Dim oThread As New System.Threading.Thread(AddressOf oNeedle.Baz)
' Set the Thread name to "MainThread".
oThread.Name = "MainThread"
' Starting the thread invokes the ThreadStart delegate
oThread.Start()
End Sub