?
Solved

using a timer in a CWinThread base class

Posted on 1998-08-13
1
Medium Priority
?
636 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 100 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

752 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