Try this. You have to delcate the function you wand called at the beginning
of the class as a delegate.
Then you have to create a class inside the main class which contains the
variables you need to send into the function. Also create a function with no
paramaters that will call the delegate
Then you create the actual function that the thread will call. it's
paramaters must match the Delegate.
Then create an instance of the class in the calling function. set the
variables and the address of the function being called in the class.
Private Delegate Sub DeleteDelegate(ByVal MessageAs String) 'Paramaters must
match the function being called
Private Class DeleteArgs
Public cMessage As String
Public StartDelegate As DeleteDelegate 'instance of function to call
Public Sub DeleteFiles()
StartDelegate(cMessage)
End Sub
End Class
Public Sub DeleteFiles(ByVal pMessage As String)
msgbox(pMessage)
End Sub
public sub FunctionToLaunchThreads()
Dim ca As DeleteArgs 'instance of class
Dim t As Thread
ca = New DeleteArgs
ca.cMessage = "Testing the threading function")
ca.StartDelegate = AddressOf DelFiles 'set the function to call
t = New Thread(AddressOf ca.DeleteFiles) 'set the thred to the function of
the class
t.Name = "Thread Delete Old Files"
t.ApartmentState = ApartmentState.MTA
t.Start()
end sub
Brad Shook
"Eric Sabine" <mopar41@mail_after_hot_not_before.com> wrote in message
news:eV****************@TK2MSFTNGP12.phx.gbl...
2 articles
http://www.devx.com/dotnet/Article/11358/
http://msdn.microsoft.com/library/de...procedures.asp
Sam Learner wrote: Hello everyone,
I am developping an application, I create a thread for the application
because it is about to download a large file, and wanted it to do it
inside of a thread... Now, the function I need the thread to call has
a parameter...
How do I call a function with the addressof(..) with a parameter
value?
for example:
public function processData(byval data as arraylist) as boolean....
...
end function
dim thrd as new thread(addressof(processData))
thrd.start( )
I have not be able to find a way to pass a value to data...
Please help...
SJ