Adam,
| Hmmm, looking at some code this only seems to be doable if the sub is in a
| class.
Look again, the target of a Delegate can be in a Module, Structure, or a
Class. It can also be a shared method of a Class or Structure.
For example:
Public Module MainModule
Private Sub Work(ByVal obj As Object)
Dim parameter As String = TryCast(obj, String)
... do stuff based on parameter ...
End Sub
Public Sub Main()
Dim worker As New Thread(AddressOf work)
Dim parameter As String = "Something"
worker.Start(parameter)
... wait for thread to finish ...
End Sub
End Module
Notice that the sub is in a Module. If I needed to pass more then one
parameter, I would consider passing a structure or a class...
NOTE: 'ParameterizedThreadStart' is new to .NET 2.0 (VS 2005)
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Adam Honek" <Ad*******@Webmaster2001.freeserve.co.uk> wrote in message
news:OW**************@TK2MSFTNGP03.phx.gbl...
| Hmmm, looking at some code this only seems to be doable if the sub is in a
| class.
|
| Can't see anything if the sub is in a module,
|
| Adam
|
| "Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
| news:%2****************@TK2MSFTNGP03.phx.gbl...
| > "Adam Honek" <Ad*******@Webmaster2001.freeserve.co.uk> schrieb:
| >> Is it honestly true we can't start threads in VB.net 2005 if the sub or
| >> function has paratemeters like functioname(x1 as string, x2 as long)
etc?
| >
| > Check out the 'ParameterizedThreadStart' delegate.
| >
| > --
| > M S Herfried K. Wagner
| > M V P <URL:http://dotnet.mvps.org/>
| > V B <URL:http://classicvb.org/petition/>
|
|