Two settimers at the same time

Dear experts,

I need to have two timers which time two different actions in my app.
Is it possible to have two timers at one time? If yes, how can I achieve this?

AphroditusAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
elston_saConnect With a Mentor Commented:
#define TIMER1 1
#define TIMER1 2

//SetTImer 1
SetTimer(
MainframeHandle, // handle to window
TIMER1,// timer identifier
100, // time-out value
NULL // timer procedure
);

//SetTImer 2
SetTimer(
MainframeHandle, // handle to window
TIMER2,// timer identifier
100, // time-out value
NULL // timer procedure
);

......Now overide the,

OnTimer( UINT nIDEvent );

function of Mainframe Class and put the following code

switch (nIDEvent)
{
  case TIMER1:
   //Action  One
 
  case TIMER2:
  //Action two
};
0
 
bertpCommented:
yes, just use different IDs when setting up the timers.   parameters sent with the WM_TIMER message will tell you which timer the message is servicing
0
 
chensuCommented:
Yes, just use different timer IDs as bertp already said. See

http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/psdk/winui/timers_1voy.htm
0
 
chensuCommented:
elston_sa's code is almost the same as the code shown on the page I provided.
0
 
AphroditusAuthor Commented:
Thanks! It works well...
Thanks to you too chensu. :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.