MFC中的准确工作计时器

MFC中的准确工作计时器

本文介绍了MFC中的准确工作计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个分析器,它通过网络连续发送消息(数据包).
例如:-2条消息-每50毫秒发送一条消息1;每100毫秒发送一次Message2.实际上,用户是通过编辑框输入50毫秒和100毫秒.
对于计时器,我首先实现了OnTimer(),SetTimer和KillTimer函数.但是此计时器的准确性不高,因为发送消息的持续时间低至50毫秒.
因此,我现在使用了一个回调函数,并使用了"timeSetEvent".这次,在要求的时间延迟内准确地发送了消息.但是,经过一段时间的工作后,计时器会挂在回调函数内部.

是因为我没有在单独的线程中实现计时器吗?如何实现"timSetEvent",以便连续工作?
请帮助我.

Hi, I am doing a Analyser which sends messages(packets) over a network continously.
Eg:- 2 messages - Message1 at every 50 ms; and Message2 at every 100 ms. The 50ms and 100 ms is actually input from the user through an edit box.
For the timer, i first implemented OnTimer(), SetTimer and KillTimer functions. But this timer was not so accurate as the time duration for sending message becomes as low as 50ms.
So I used now a callback function, and used "timeSetEvent". This time the messages were sent accurately at the required time delays. But after some time of working, the timer hangs inside the call back function.

Is it because i have not implemented the timer in a seperate thread? How can i implement the "timSetEvent", so as to work continously?
Please help me.

推荐答案



这篇关于MFC中的准确工作计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:06