Home > Software engineering >  I use the timer SetTimer, program rose from 0 to 30% CPU utilization, why? Program card
I use the timer SetTimer, program rose from 0 to 30% CPU utilization, why? Program card

Time:09-16

 
The SetTimer (NULL, 1, 1000, & amp; PrintSTR);
The SetTimer (NULL, 2, 10000, & amp; PrintFa);


I use the timer SetTimer, program rose from 0 to 30% CPU utilization, why? Program card

CodePudding user response:

That should see printSTR printFa in do? Timer message priority was very low, but the call is also go message queue
General running time longer call, it is recommended to use a background thread to manipulate



CodePudding user response:

What did you do in the callback function operation?

CodePudding user response:

I put the callback function the delete deleted, then system CPU utilization have recovered,

CodePudding user response:

Blast die use less as far as possible inside timer, consider multi-purpose thread

CodePudding user response:

reference zxy_net reply: 3/f
I put the callback function the delete deleted, then system CPU utilization has recovered,




The task of the timer can't be done for a long period of time, don't block the timer

CodePudding user response:

What are you doing in OnTimer, of the CPU is accounted for in this function

CodePudding user response:

Is that your timing handler, CPU, this function is going to quit soon

CodePudding user response:

A timer handler simply and quickly, as far as possible
If more complex, can consider to the thread pool,

CodePudding user response:

The timer is used to do simple things best, what is simple, such as you want to do one thing after 3 seconds, you can use the timer, finished off, this name is simple,

If driven to do things, such as long time query a certain things, so will lead to system CPU utilization rate is high, this kind of situation, in the thread line directly,
  • Related