C#UWP TIMER [英] C# UWP TIMER
本文介绍了C#UWP TIMER的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
字符串o =" X =" + vals [0] +" Y =" + vals [1] +" Z =" + vals [2];
if(vals [0]!=" 225.0"&& vals [1]!=" 225.0"&& vals [2]!=" 225.0")
{
txtTimer.Interval = TimeSpan.FromSeconds(3);
txtTimer.Tick + = txtTimer_Tick;
txtTimer.Start();
}
private void txtTimer_Tick(object sender,object e)
{
updateText.Text =" Connection好的。你已经准备好开始锻炼了。他们继续第3步。"
}
我想设置一个计时器,如果我的x,y,z值是225.0,它将显示一个文本。但文本将在3秒后显示。这是我做的代码,但它不起作用。为什么会这样?
解决方案
您的帖子未启动一般性讨论。所以,最好把它作为一个问题。
你的行:
txtTimer 。 Interval = TimeSpan 。 FromSeconds ( 3 );甚至不应该编译,因为属性Interval是double类型,而方法FromSeconds()返回TimeSpan对象。你可以尝试:
txtTimer 。 Interval = TimeSpan 。 FromSeconds ( 3 )。TotalMilliseconds;wizend
String o = "X=" + vals[0] + " Y=" + vals[1] + " Z=" + vals[2]; if (vals[0] != "225.0" && vals[1] != "225.0" && vals[2] != "225.0") { txtTimer.Interval = TimeSpan.FromSeconds(3); txtTimer.Tick += txtTimer_Tick; txtTimer.Start(); }
private void txtTimer_Tick(object sender, object e) { updateText.Text = "Connection okay. You're ready to start your exercise.\nProceed to Step 3."; }
I want to set up a timer where if my x,y,z values are 225.0 , it will display a text. But the text will be shown 3 seconds later. This is the code I did but it doesnt work. Why is this so ?
解决方案
Your post does not launch a General Discussion. So, better make it a Question.
Your line:
txtTimer.Interval = TimeSpan.FromSeconds(3);shouldn't even compile, because the property Interval is of the type double whereas the method FromSeconds() returns a TimeSpan object. You could try:
txtTimer.Interval = TimeSpan.FromSeconds(3).TotalMilliseconds;wizend
这篇关于C#UWP TIMER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文