Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

using a timer in a CWinThread base class

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

609 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