如何检查ceratin一段时间内variant的值没有变化? [英] How to check the value of varial haven't changed for a ceratin period of time?

查看:50
本文介绍了如何检查ceratin一段时间内variant的值没有变化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我需要检查变量的值是否在固定的时间段内(例如2秒)已更改或为常量(允许轻微变化).

我想到了运行一个并行线程,该线程在一定的sleep()持续时间后仍会检查变量,但会使应用程序变慢.

还有其他想法吗?

谢谢!

Hi Every.One!

I need to check the value of a variable for if it has changed or is constant(slight variation allowed) in fixed duration of time(say 2sec).

I thought of running a parallel thread that keeps checking the variable after a certain sleep() duration but that slows down the application.

Any other idea?

Thanks!

推荐答案

我想您可以使用计时器.此计时器不应减慢您的应用程序的速度:

http://msdn.microsoft.com/en-us/library/system.threading. timer.aspx [ ^ ]

但是为什么要这样呢?
使用一个在值更改时(变化大于x%时)触发事件的属性难道不是很容易吗?
I guess you could use a timer. This timer shouldn''t slow your application:

http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx[^]

But why this approach?
Isn''t it easier to use a property which fires an event when the value changes (when variation is more than x%)?


这篇关于如何检查ceratin一段时间内variant的值没有变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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