How to set such a Timer

Can a thread class owns a timer? How to get the timer message and handle it? And how to implement that all the instances of the thread class have their own timer?
yclAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

WynCommented:
For my knowledge,only a window can own a timer.You can create a hidden window in each thread.
Regards
Wyn
0
shaigCommented:
Two options:
1) Use the windows timer- very inaccurate, second, the WM_TIMER message is in the lowest priority to be proccessed.
2) Use the multimedia timers, this way you can assign a timer to anything you want (includung a thread). This does have a problem though, the max interval is limited to a certain undocumented value (round 15 seconds i think).

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ToronadoCommented:
Hi ycl,

You can use the global timer functions.

UINT SetTimer (
 HWND hWnd, // handle of window for timer messages
 UINT nIDEvent, // timer identifier
 UINT uElapse,  // time-out value
 TIMERPROC lpTimerFunc   // address of timer procedure);

The hWnd parameter can be set to the hWnd of you mainwindow. Set the nIDEvent to a number specific to a thread instance. You will receive this number in your TIMERPROC.

Regards,
 Toronado.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

shaigCommented:
Once again, the window timers are very inaccurate and unreliable.
0
WynCommented:
?
ycl,what do you want?
I'm confused by the answer and comment.

Again,only windows can own a timer.You can create windows in threads.

Regards
Wyn
0
shaigCommented:
Wrong my man, One windows can have WINDOW TIMERS.
You can create multimedia timers that don't have nothing to do with window objects.
0
WynCommented:
>>You can create multimedia timers that don't have nothing to do with window objects.

Please read the question again,shaig.
0
WynCommented:
timer here refer to the mechanism ejecting wm_timer message.
0
shaigCommented:
Please reread my answer Wyn, I suggested the multimedia timers as a better solution to a givven problem. I one doesn't know of an option, how can he ask about it.
Should I misslead him by directing him only in directions he already knows?
0
WynCommented:
>>Wrong my man, One windows can have WINDOW TIMERS.

Okay,would you please tell me what this means? I dont understand it.
Regards
Wyn
0
shaigCommented:
Sorry bout' the spelling: 'One' means 'Only'.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.