EVC programming bit by bit-wm_timer conflict processing and Accuracy

Source: Internet
Author: User

Two points about wm_timer will be described in this article:
(1) wm_timer response conflict
(2) Accuracy of time

(1) wm_timer response conflict: processing when multiple wm_timers arrive at the same time
First, the priority of the message wm_timer is very high. Similarly, there are wm_paint messages. The two messages are executed only when there are no other messages in the message queue.
The wm_timer message is a low-priority message. the getmessage and peekmessage functions retrieve this message only when no other higher-priority messages are in the thread's message queue.

During this period, we will discuss the timer message in csdn Hardware/Embedded Development> embedded development (wince). For details, see:
Http://topic.csdn.net/u/20071205/10/f97d8fed-3ea9-4a7f-a2e0-3b707f4ca264.html

There is such a line on the Internet (not authoritative ):
[When multiple wm_timer arrive at the same time, wm_timer will be generated. However, if multiple identical wm_timer come together, it will be merged.] This statement conforms to the actual test results in the above post.
However, the other paragraph is as follows:
[Multiple wm_timer messages are not loaded in the message queue. Windows will keep only one wm_timer in the message queue and discard other wm_timer.] But I didn't say how to process the wm_timer message!

Therefore, based on the test results in the post and the above text, we can draw the following conclusion: the message queue does not load multiple wm_timer; if multiple identical wm_timer are listed together, will be merged to execute the function corresponding to the last wm_timer.

* ** You are welcome to discuss this issue. The above conclusions are not necessarily correct!

(2) Accuracy of wm_timer in time
The Research on wm_timer precision is derived from the realization of stopwatch function.
At the beginning, wm_timer was used as the driving source of the stopwatch. The test showed that the stopwatch was not allowed after a while.
Of course, this period of time varies depending on the time of mw_timer. The smaller the time-out period, the shorter the time-out period. The longer the time-out period, the longer the time-out period. However, even if the 1-second interval is used, it will not work.

[Wm_timer has a precision of about 55 ms. It is enough for simple animation effects, but it is difficult to have a higher requirement.]
Wm_timer has a single precision. Generally, when you are using wm_timer, you don't have to pay much attention to it. The time is almost enough. However, after multiple wm_timer accumulation, inaccurate accuracy is obvious.
Finally, I gave up the idea of using settimer.

Search online and find that there is a multimedia timer under VC, which is a timer with high precision. For example, its function timesetevent () is not found in the evc4 help file. Just faint ......
However, tests show that timesetevent () and related functions in EVC can be used normally. It is another function that is not described in help!
Using a multimedia timer, the stopwatch function is finally implemented.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.