Solved

using a timer in a CWinThread base class

Posted on 1998-08-13
1
553 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

763 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now