MFC 定时器 多媒体定时器

大叔丶 2017-05-29 11:30:52
在使用MFC 定时器的时候,因为该定时器消息响应优先级比较低。

有没有大神,编写过像mfc的定时器,但是优先级要高。最后能后台处理任务。

给个demo 谢谢了!
...全文
487 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2017-05-31
  • 打赏
  • 举报
回复
提醒:Windows计时精度≈15ms
worldy 2017-05-29
  • 打赏
  • 举报
回复
Waitable Timer Objects A "waitable" timer object is a synchronization object whose state is set to signaled when the specified due time arrives. There are two types of waitable timers that can be created: manual-reset and synchronization. A timer of either type can also be a periodic timer. Object Description manual-reset timer A timer whose state remains signaled until SetWaitableTimer is called to establish a new due time. synchronization timer A timer whose state remains signaled until a thread completes a wait operation on the timer object. periodic timer A timer that is reactivated each time the specified period expires, until the timer is reset or canceled. A periodic timer is either a periodic manual-reset timer or a periodic synchronization timer. A thread uses the CreateWaitableTimer function to create a timer object. Specify TRUE for the bManualReset parameter to create a manual-reset timer and FALSE to create a synchronization timer. The creating thread can specify a name for the timer object in the lpTimerName parameter. Threads in other processes can open a handle to an existing timer by specifying its name in a call to the OpenWaitableTimer function. Any thread with a handle to a timer object can use one of the wait functions to wait for the timer state to be set to signaled. The thread calls the SetWaitableTimer function to activate the timer. Note the use of the following parameters for SetWaitableTimer: Use the lpDueTime parameter to specify the time at which the timer is to be set to the signaled state. When a manual-reset timer is set to the signaled state, it remains in this state until SetWaitableTimer establishes a new due time. When a synchronization timer is set to the signaled state, it remains in this state until a thread completes a wait operation on the timer object. Use the lPeriod parameter of the SetWaitableTimer function to specify the timer period. If the period is not zero, the timer is a periodic timer; it is reactivated each time the period expires, until the timer is reset or canceled. If the period is zero, the timer is not a periodic timer; it is signaled once and then deactivated. A thread can use the CancelWaitableTimer function to set the timer to the inactive state. To reset the timer, call SetWaitableTimer. When you are finished with the timer object, call CloseHandle to close the handle to the timer object.
zgl7903 2017-05-29
  • 打赏
  • 举报
回复
http://m.blog.csdn.net/article/details?id=8134064
大叔丶 2017-05-29
  • 打赏
  • 举报
回复
可等待定时器对象 “等待”定时器对象是一个同步对象的状态被设置为有信号时,由于到达指定时间。有两种可等待定时器,可以创建:手动复位和同步。任一类型的定时器也可以是周期定时器。 对象描述 手动复位定时器,定时器的状态仍然表示,直到setwaitabletimer称为建立一个新的到期时间。 同步计时器:在线程完成定时器对象的等待操作之前其状态保持信号的计时器。 周期计时器:每次指定的时间到期后重新启动的计时器,直到定时器复位或取消为止。周期定时器是周期性手动复位定时器或周期性同步定时器。 一个线程使用createwaitabletimer函数来创建一个定时器对象。指定真的bmanualreset参数创建一个手动复位定时器和假创建一个同步定时器。创建线程可以在lptimername参数计时器对象指定一个名称。其他进程中的线程可以开启一个处理到一个现有的定时器指定名称的openwaitabletimer函数调用。任何具有定时器对象句柄的线程都可以使用等待函数中的一个来等待定时器状态设置为信号。 调用线程setwaitabletimer功能激活定时器。注意以下参数的使用SetWaitableTimer: 使用lpduetime参数指定时间的定时器被设置为终止状态。当手动复位定时器被设置为信号状态,保持在这个状态直到setwaitabletimer建立了一个新的到期时间。当同步定时器设置为信号状态时,它将保持在该状态,直到线程在计时器对象上完成等待操作。 使用的setwaitabletimer功能期参数指定定时器周期。如果周期不是零,定时器是一个周期定时器,它被重新激活每次期限届满,直到定时器复位或取消。如果周期为零时,定时器不是周期性定时器,它会发出一次信号,然后停用。 一个线程可以使用cancelwaitabletimer函数来设置定时器到非活动状态。重置计时器,叫setwaitabletimer。当你完成了定时器对象,调用CloseHandle关闭处理定时器对象。
sichuanwww 2017-05-29
  • 打赏
  • 举报
回复
用多线程定时吧,既可以设置优先级又能比较准确的计时。

15,471

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 进程/线程/DLL
社区管理员
  • 进程/线程/DLL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧