Re: Threads help
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Fri, 20 Jun 2008 09:00:11 -0700
Seems like we've had this discussion in this group before. Have you checked
the archives?
The pattern goes something like this:
-----
// This event will be set when you want the thread to exit.
protected AutoResetEvent thev = new AutoResetEvent( false );
startbutton_click()
{
th = new Thread( new ThreadStart( this.MyThread ) );
th.Start();
}
protected virtual void AcqThread()
{
while (thev.WaitOne(time, false) == false)
{
}
// The event was set. Time to exit the thread...
}
stopbutton_click()
{
thev.Set();
th.Join(waittime);
}
-----
Paul T.
"Armando Rocha" <armandorocha@xxxxxxxxxxxxxxxxxx> wrote in message
news:38439AF5-A90E-4D39-9877-011CCA196E7E@xxxxxxxxxxxxxxxx
Hi,
I want a know if is possible launch a separeted thread that run with a
interval of time like a Timer object (Timer.Tick).
my goal is put to buttons (Start and Stop), when user click Start i want
launch a thread that do something with a interval of 30 seconds at least,
but user can work normaly, but when user click Stop i want also stop
thread.
--
Armando Rocha
Mobile Developer
http://www.ifthensoftware.com
PORTUGAL
.
- Follow-Ups:
- Re: Threads help
- From: Armando Rocha
- Re: Threads help
- From: Paul G. Tobey [eMVP]
- Re: Threads help
- References:
- Threads help
- From: Armando Rocha
- Threads help
- Prev by Date: Threads help
- Next by Date: Re: Threads help
- Previous by thread: Threads help
- Next by thread: Re: Threads help
- Index(es):