C ++多个计时器同步 [英] C++ Multiple Timers synch

查看:115
本文介绍了C ++多个计时器同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我们假设我必须为win32 / MFC应用程序设置2个不同的计时器。

我们假设第一个定时器在60ms后经过,第二个定时器在30ms后过去,第一个定时器的回调函数需要40ms才能结束执行。



在这种情况下30ms的功能定时器执行延迟,因为当第二个定时器触发时,其他功能仍在执行。



如何避免这种延迟?



我要使用多个线程吗?



谢谢

Hello everybody,

Let's suppose I have to set 2 different timers for a win32 / MFC Application.
Let's suppose that the first timer elapses after 60ms and the second after 30ms and that the callback function of the first timer takes 40ms to end the execution.

In this situation the function of the 30ms timer execute with a delay because the other function is still executing when the second timer triggers.

How is it possible to avoid this delay?

Have I to use multiple thread?

Thank You

推荐答案

您需要多个线程,在多个CPU核心上运行(您知道单个CPU无法实现这一点)。
You need multiple threads, running on multiple CPU cores (You know a single CPU cannot accomplish that).


这篇关于C ++多个计时器同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆