Solved

using a timer in a CWinThread base class

Posted on 1998-08-13
1
604 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

726 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