question

MarkusFreitag-0088 avatar image
0 Votes"
MarkusFreitag-0088 asked MinxinYu-MSFT edited

Timer - Time window for C++

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

c++dotnet-cli
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MinxinYu-MSFT avatar image
1 Vote"
MinxinYu-MSFT answered MinxinYu-MSFT edited

Hi, @MarkusFreitag-0088

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.


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks.
Which timer is best suited for periodic queries?
How would I implement a stopwatch?


Sample for a timeline
StartTime Split1Time Split2Time EndTime

0 Votes 0 ·
RLWA32-6355 avatar image RLWA32-6355 MarkusFreitag-0088 ·

Is it your intent to use a timer to poll for the completion of some event?

0 Votes 0 ·
MinxinYu-MSFT avatar image MinxinYu-MSFT MarkusFreitag-0088 ·

Which timer is best suited for periodic queries?

It's hard to answer. Are you dissatisfied with the timer you are currently using?

SetTimer parameter uElapse: The time-out value, in milliseconds.

Sample: Using Timers



0 Votes 0 ·