How to use thread for function with parameters.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have thread declared in this way. Dim t As New Thread(AddressOf
ThreadProc). Here ThreadProc is a function with two parameters. But i am not
able to use function name with addressof, It accepts only if it is 'Sub' and
not 'function'.
Can anyone help me with some good example, to use thread for functions with
some parameters.

thanking u,

regards,
Sivaraman.S
 
Hi Sivaraman,

The common practice , I beleive, is to encapsulate your method in some class
, or have the arguments as member variables of the class which the function
is part of.
Then before calling the start method set the variables.
The threaded function will then use these variables.
These variables must be shared/static as the thread function also needs to
be the same.

See the following Google Group Thread for some code example nearly
equivalent to above description.
http://tinyurl.com/3v4u8

HTH
rawCoder
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top