I've been using CF for quite a while but have not goettn into the threading
portion much at all. I've found some decent articles regarding it. My boss
asked me if I could "Start a timer on a seperate thread" and I really didn't
know what to tell him - i knew we could execute a method on a thread but
figured we could also control a timer's start event too. Is there any
reason why this could not be done in CF 2?
TIA
Harry
Christian Resma Helle - 25 Aug 2007 09:05 GMT
Hi Harry,
If you want to access a System.Windows.Forms.Timer from a thread then you
have to use Control.Invoke(). Something like this:
static void ThreadWorker() {
this.Invoke(new EventHandler(TickerStartMethod));
}
void TimerStartMethod(object sender, EventArgs e) {
// Do stuff to your Timer...
}

Signature
Regards,
Christian Resma Helle
http://christian-helle.blogspot.com
> I've been using CF for quite a while but have not goettn into the
> threading portion much at all. I've found some decent articles regarding
[quoted text clipped - 5 lines]
> TIA
> Harry
<ctacke/> - 25 Aug 2007 16:08 GMT
Use the System.Threading.Timer class. That starts a thread. A Forms timer
should only be used on the primary thread.

Signature
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com
> I've been using CF for quite a while but have not goettn into the
> threading portion much at all. I've found some decent articles regarding
[quoted text clipped - 5 lines]
> TIA
> Harry
Simon Hart - 28 Aug 2007 21:12 GMT
Harry,
just to add to what Chris said, the simple rule of thumb which is easy to
remember is; only ever use the System.Windows.Timer class within your UI
code/thread not within worker thread code and use System.Threading.Timer
otherwise.

Signature
Simon Hart
http://simonrhart.blogspot.com
> Use the System.Threading.Timer class. That starts a thread. A Forms timer
> should only be used on the primary thread.
[quoted text clipped - 8 lines]
> > TIA
> > Harry