Solved

using a timer in a CWinThread base class

Posted on 1998-08-13
1
582 Views
Last Modified: 2012-05-04
I will use a timer in my methode but my base class of my class is CWinThread and i can not use SetTimer()
and Event timer handling function OnTimer, can you write me a solution.

                                           thank you

i have a code fragment like this code:
i use MFC and implement in visual c++ 5.0.

class A public:CWinthread

 A::Run(){

  setTimer(1,1000,NULL);  <--------- ilegal base class is not CWnd
  while(!timerEvent)
  {
    do anything}
 killTimer(1);                    <--------- ilegal base class is not CWnd

void A::Ontimer(UINT nIDEvent){       <--------- CWinThread has not a timer event handler what is alternate solution.
if(nIDEvent==1)
  timerEvent=true;
}
0
Comment
Question by:saidi
1 Comment
 
LVL 6

Accepted Solution

by:
snoegler earned 50 total points
ID: 1170199
If i understood this right, you only want to wait for a certain time to elapse and during this
time you want to 'do anything' ...
Then you could perhaps code it like this:
DWORD curTickCount=GetTickCount(); // msec since windows started up
while( (GetTickCount()-curTick)<=_time_to_wait_in_msec) {
  // do anything
}
Hope that helps
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

773 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