Regarding thread

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

Guest

hi,

I have created a thread and called a method from it. Now i want to use the
same thread to execute another method.
This is how i have used.
thread1 = New Thread(AddressOf Method1)
I want to use the same thread "thread1" to execute another method "method2".
How can i do this. Is there any other way to do this?

regards,
Sivaraman.S
 
How can i do this. Is there any other way to do this?

Check out the QueueUserWorkItem in the docs. It lets you use the
threadpool to spin off threads. You don't need to create them yourself
necessarily.

Basically, your sub would have the following signature:

Shared Sub DoWork(stateInfo As Object)
'Code to execute here
End Sub

Then you kick off a thread like this:

ThreadPool.QueueUserWorkItem(AddressOf DoWork)

..Net manages the thread pool.

When you use this method, you don't have control of the threads. Plus, by
default, there is an application wide limit of 25 threads in the thread
pool.

HTH


--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Back
Top