in threading am i allowed to thread a function wich has paramentrs?
i tryed
dim MyThread as thread
MyThread=new Thread(adress of downloadfile(url,filename))
and it is not working..any ideas..?
Printable View
in threading am i allowed to thread a function wich has paramentrs?
i tryed
dim MyThread as thread
MyThread=new Thread(adress of downloadfile(url,filename))
and it is not working..any ideas..?
another error...
C:\Documents and Settings\JBRANCO\My Documents\Visual Studio Projects\thread test\Form1.vb(94): Method 'Public Function DownloadPic() As Object' does not have the same signature as delegate 'Delegate Sub ThreadStart()'.
ahhh..seems like i can only put in addressof **** sub's and not funcions... :(
The entrypoint for the thread must match the delegate definition used in the thread class's constructor:
<Serializable>
Public Delegate Sub ThreadStart()
This means the entrypoint must be parameterless and must be a sub. If you need parameters, you have to make properties for them, so you can first set the properties, and then start the thread with a parameterless sub. You can then use the properties instead of the missing parameters.
Editted: It would not make any sense to start a thread at a function.
You would have to wait to get the return value, so the benefit of a seperate thread would be vanished.
Just a note, you can just have your method raise an event when it is done. Then pass in as arguements the value(s) you want to return.