Skip to main content
 首页 » 编程设计

c#之dispatcherTimer 不能正常工作

2024年02月13日19kevingrace

我需要用实时摄像机每秒捕捉 10 帧,持续 15 分钟。我使用了 dispatcherTimer 类,但它似乎不能正常工作。如何做到准确?我什至不保存图像,因为它很耗时,我只是将它保存在内存中,但它仍然无法正常工作。 我应该使用另一个图书馆吗?

counter01 = new DispatcherTimer(); 
counter01.Tick += new EventHandler(counter01_Tick); 
counter01.Interval = new TimeSpan(0, 0, 0,100); // every 100 milliseconds == 10 frames per seconds 

请您参考如下方法:

MSDN states那:

Timers are not guaranteed to execute exactly when the time interval occurs, but they are guaranteed to not execute before the time interval occurs.

可以查看StopWatch ,它可能对你有帮助。