Passing Parameters

In many cases you might have the need to pass data to new threads. This can be accomplished by creating an instance of the ParameterizedThreadStart delegate, which requires an argument of type Object that you can use for sharing your data. The following code demonstrates how you create a thread with parameters:

image

Notice how the Thread.Start method has an overload that takes the specified parameter as the data. Because such data is of type Object, you need to convert it into the most appropriate format. The following code demonstrates how to implement a method that the delegate refers to and how to convert the data into a hypothetical ...

Get Visual Basic® 2010 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.