I don't know if it is possible to do it with a non-member function. What I
usually do in this situation would be to declare a class that takes the
arguments I need in its constructor and then make the method I want to call
have no parameters so I can use it on the thread.
For Example:
Public Class ThreadWorker
Private path as String
Public Sub New(filePath as String)
path = filePath
End Sub
Public Sub MySub()
If File.Exists(path) Then File.Delete(path)
End Sub
End Class
....
Dim worker as new ThreadWorker("C:\test.txt")
Dim t as new Thread(AddressOf worker.MySub)
t.Start()
Hope this helps,
Brian
"Amjad" wrote:
Hi,
To start a new thread of a sub routine I use:
'///////////
Dim t as Thread = New Thread (AddressOf MySub)
t.Start
'\\\\\\\\\\\
How do I start a thread of a sub routine that takes parameters?
For example:
'////////////
Sub MySub (filePath as String)
if File.Exists(filePath) Then File.Delete(filePath)
End Sub
'
'
Dim t as Thread = New Thread (AddressOf MySub("C:\test.txt"))
t.Start
'
'\\\\\\\\\\\\\\\