使用间隔可变的计时器. [英] Using Timers with variable intervals.

查看:85
本文介绍了使用间隔可变的计时器.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在指定的时间后将不同的数据包发送到串行端口.我现在可以发送和接收单个字符串.例如,让A,B,C为三个字符串.首先,我发送A,然后在时间"x"之后发送B,然后在时间"y"之后发送C,在时间"z"之后再次发送A .....依此类推. br/>
SetTimer函数以固定的间隔触发.如何像我的示例一样以不规则的间隔触发?
是此处使用的CreateTimerQueueTimer函数.如果可以,那么您可以举一个如何使用它的示例.


欢迎任何帮助.

I need to different data packets to serial port after specified amounts of time. I can send and receive a single string presently. For example let A, B, C be three strings. First I send A, then after time ''x'' I send B, then after time ''y'' I send C, after time ''z'' I again send A..... and so on.

SetTimer function is triggered in regular intervals.how do i make it trigger at irregular intervals as in the case of my example??
Is CreateTimerQueueTimer function of use here.if so can you give an example on how to use it.


Any help will be welcome.

推荐答案

Gautam Raiker写道:
Gautam Raiker wrote:

是CreateTimerQueueTimer函数如果可以的话,您可以举一个例子来说明如何使用它.

Is CreateTimerQueueTimer function of use here.if so can you give an example on how to use it.


这只是一个延迟启动的常规(即定期)计时器.

我看到三个选择:

  • 如果您的间隔具有一个合理的"除数,则可以使用它来设置常规计时器.
  • WM_TIMER消息处理程序中,终止该计时器,然后使用适当的不同时间段
  • 使用许多(不要太多!)计时器

  • This is just a regular (i.e. periodic) timer with delayed start-up.

    I see three options:

    • if your intervals have a ''reasonable'' common divisor then use it to set a regular timer.
    • In the WM_TIMER message handler kill the timer and then set it again with the proper,different period
    • Use many (not too many!) timers

    • 这篇关于使用间隔可变的计时器.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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