Timer - Time window for C++

Markus Freitag 3,786 Reputation points
2022-09-07T19:00:48.63+00:00

Hello,
I am not so familiar with C++.
What do I need?

void CustomStandard::ProccessA(void)  
{  
	StartTimer(1, 1000);  
	// TimerID, Timout in ms  
	Call RequestProccessA();  
}  
  
// Event  
void CustomStandard::ReceivedProcessA(string ret)  
{  
	KillTimer(1);  
	// TimerID, Timout in ms  
	// Analyse the ret string  
}  
  
// CallBack   
void CustomStandard::OnTimer(int id)  
{  
	switch(id)  
	{  
	  default:  
	      break;  
      case 1:   
	     KillTimer(1) // Is needed or do it automatically?  
		    
	}  
}  

How can I achieve this?
Which timer is suitable for this?

I need to start an action and in a certain time window a response must come back.

Thanks for tips.

C++, MFC, VS2017
Maybe in future with C++/CLI

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
322 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,519 questions
0 comments No comments
{count} votes

Accepted answer
  1. Minxin Yu 9,866 Reputation points Microsoft Vendor
    2022-09-08T02:21:45.177+00:00

    Hi, @Markus Freitag

    Set timer example: SetTimer(1, 1000,NULL);
    You can put KillTimer in OnTimer event.

    Best regards,

    Minxin Yu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful