Re: Threads help



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


.