Thread Suspend and Resume

M

Mike Fellows

Having not used threads for such a long time in vb.net I have found myself
in need of them

I have a thread that runs and retirieves live data from a SQL database, this
is running fine and has been doing its job for a long time

the problem is I need to suspend this thread when a checkbox is clicked (as
the data is no longer required) but when the checkbox is unclicked it needs
to restart

simple enough i thought Suspend/Resume exist, problem is as im sure your
aware, these appear to be on the way out (and will be removed completely
from the next version of the .net framework!!)

how do i now suspend/restart a thread without using defunct code???

ive searched the web for this and everything still points to suspend/resume,
which is of little help to me

thanks in advance

Mike Fellows
 
A

Armin Zingler

Mike Fellows said:
Having not used threads for such a long time in vb.net I have found
myself in need of them

I have a thread that runs and retirieves live data from a SQL
database, this is running fine and has been doing its job for a long
time

the problem is I need to suspend this thread when a checkbox is
clicked (as the data is no longer required) but when the checkbox is
unclicked it needs to restart

simple enough i thought Suspend/Resume exist, problem is as im sure
your aware, these appear to be on the way out (and will be removed
completely from the next version of the .net framework!!)

how do i now suspend/restart a thread without using defunct code???

ive searched the web for this and everything still points to
suspend/resume, which is of little help to me

thanks in advance

Mike Fellows


Simplest way is setting a boolean flag to have a Thread wait for something.
Then use an event (for example AutoResetEvent) set from outside to let the
Thread continue.


Armin
 

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

Top