C# Windows CE Timer

gokuhama

Member
Sep 22, 2004
59
0
0
Does anyone know how to set a timer event in c# for windows ce? CE doesn't have a System.Timer and I tried using System.Windows.Forms.Timer but it didn't fire at the interval. Is there another timer I should try using or has anyone had any experience with the windows.forms.timer. Thanks.
 

imported_Dhaval00

Senior member
Jul 23, 2004
573
0
0
System.Threading.Timer: Use this when you need to perform periodic background tasks on another thread. To cut to the chase, ALWAYS use this.

System.Windows.Forms.Timer: This actually dispatches a request for callback in the originating thread's message queue. Meaning the thread that sets the timer is guaranteed to be the thread that executes the callback! This also means that only one thread is doing all the work.

System.Timers.Timer: This is a wrapper around System.Threading.Timer. LMAO.


If your understanding of threads is competent, I would suggest not using a timer for a server application. I have always experienced timers not "going-off" when the server is quite busy. I usually end up using an endless loop on a background thread, do all my work, and then call Thread.Sleep(), thus allowing other threads to do their work. Hope this helps.


Edit: I didn't notice before that you were using the compact framework. In any case, regarding the last strategy I shared - you may want to be mindful of the battery life/resources on the mobile device (if you end up adopting the strategy).
 

formulav8

Diamond Member
Sep 18, 2000
7,004
522
126
The only timer that comes to mind available in the compact framework is the GetTickCount counter. And as someone else pointed out there should be a "Timer" class if your wanting to raise timer events. I unfortunately do not know much about the compact framework...:confused:


Jason