[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to set such a Timer

Posted on 2000-01-19
11
Medium Priority
?
261 Views
Last Modified: 2013-11-20
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?
0
Comment
Question by:ycl
  • 5
  • 5
11 Comments
 
LVL 5

Expert Comment

by:Wyn
ID: 2369575
For my knowledge,only a window can own a timer.You can create a hidden window in each thread.
Regards
Wyn
0
 
LVL 3

Accepted Solution

by:
shaig earned 200 total points
ID: 2369992
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
 

Expert Comment

by:Toronado
ID: 2369998
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Expert Comment

by:shaig
ID: 2370035
Once again, the window timers are very inaccurate and unreliable.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2371413
?
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
 
LVL 3

Expert Comment

by:shaig
ID: 2377112
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
 
LVL 5

Expert Comment

by:Wyn
ID: 2377431
>>You can create multimedia timers that don't have nothing to do with window objects.

Please read the question again,shaig.
0
 
LVL 5

Expert Comment

by:Wyn
ID: 2377433
timer here refer to the mechanism ejecting wm_timer message.
0
 
LVL 3

Expert Comment

by:shaig
ID: 2377493
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
 
LVL 5

Expert Comment

by:Wyn
ID: 2377553
>>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
 
LVL 3

Expert Comment

by:shaig
ID: 2386850
Sorry bout' the spelling: 'One' means 'Only'.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
Suggested Courses

608 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question