Naming Threads

Name spaces to be used are

System.Threading



Names can be provided for threads



Imports System.Threading
Class workerclass
Public Sub dosomework()
Console.WriteLine("secondary thread:")
Dim i As Integer
For i = 0 To 10

Console.WriteLine(i & ",")


Next
Console.WriteLine()
End Sub
End Class
Module Module1

Sub Main()
Dim primarythread As Thread = Thread.CurrentThread

primarythread.Name = "BOSS"
Console.WriteLine("primary thread..")
Dim w As workerclass = New workerclass()
Dim backgroundthread As Thread = New Thread(AddressOf w.dosomework)
backgroundthread.Name = "secondary thread"
backgroundthread.Start()



End Sub

End Module




Explanation: just for clarity we use names for threads which can be achieved through name property.


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: