Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Setting a Thread Name (Managed)

To set a thread name in managed code, use the Thread.Name property of the .NET Framework Thread class:

Public Class Form1 : Inherits Form
    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

    Public Shared Sub Main()
        Console.WriteLine("Thread Simple Sample")
        Dim oNeedle As New Needle()
        ' Create a Thread object 
        Dim oThread As New Thread(AddressOf oNeedle.Baz)
        ' Set the Thread name to "MainThread"
        oThread.Name = "MainThread"
        ' Starting the thread invokes the ThreadStart delegate
    End Sub
End Class

See Also

Using the Threads Window | Threads Window | Debugging Tools for Inspecting Your Program | Setting a Thread Name (Unmanaged) | Visual Studio Debugger Model | Thread.Name Property | Thread Class

© 2015 Microsoft