difference between Timer and Thread?

What's the difference between Timer and Thread???

(SetTimer and CreateThread)

Both are same? or different?

I want to know.

Please, let me understand it. Thanks.
One creates a timer. One spawns a separate thread.

A timer triggers a WM_TIMER event after a certain time. Your program can respond to these events to be notified after a certain period of time has passed.


A thread is... well.... a thread.
http://en.wikipedia.org/wiki/Thread_%28computing%29

Threads run in parallel so it's like having your program doing two separate things simultaneously.
Let me make a little scheme, hoping this will be useful for you:


Using Timers:

Main Program
\-> Entrypoint
        \-> Message Loop
                 \-> Your WM_TIMER handling procedure
				 
Using Threads:

Main Program
\-> Entrypoint
\-> Thread Entrypoint
\-> ...Other threads entrypoints


As you can see, Timers are "Part" of your program flow, where a Thread is not, it runs on its own, so it won't block your main program flow. Also, it does not require a message loop, but it can be used to call a specific function (see TimerProc).
Last edited on
Timers are "Part" of your program flow, where a Thread is not, it runs on its own

I got that!!!

Thanks All!!!!
Topic archived. No new replies allowed.