Creating Threads

You create a new thread for performing an operation with an instance of the System.Threading.Thread class. The constructor of this class requires you to also specify an instance of the System.Threading.ThreadStart delegate that points to a method that can actually do the work. Then you invoke the Thread.Start instance method. The following code snippet demonstrates how you can create a new thread:

Private Sub simpleThread()    Dim newThread As New Thread(New ThreadStart(AddressOf _                                                executeSimpleThread))    newThread.Start()End SubPrivate Sub executeSimpleThread()    Console.WriteLine("Running a separate thread")End Sub

To actually start the new thread, ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.