使用线程重新获取代码 [英] Reapting code using threading
本文介绍了使用线程重新获取代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想重新编写一个代码,所以我使用了一个间隔为500的计时器,但这可能是使用线程吗?如果是,任何人都可以帮我这个。
代码重复500区间:
Hi all,
I want to reapeat a code so I used a timer with 500 as interval, but this noticeable is this possible using threading? if yes could anyone help me with this please.
code to be repeated with 500 interval:
if (checkBox2.Checked)
{
PointOnTerrainGE pot = ge.GetPointOnTerrainFromScreenCoords(0, 0);
label1.Text = pot.Altitude.ToString();
label2.Text = pot.Latitude.ToString();
}
谢谢大家。
Thank you all.
推荐答案
您好,
编写如下代码。
Hi,
Write code like below.
Timer timer = new Timer();
public FormWithTimer()
{
timer.Tick += new EventHandler(Method_Do); //Method_Do will be called
timer.Interval = (500) * (1);
timer.Enabled = true;
timer.Start();
}
public void Method_Do(object sender, EventArgs e)
{
if (checkBox2.Checked)
{
PointOnTerrainGE pot = ge.GetPointOnTerrainFromScreenCoords(0, 0);
label1.Text = pot.Altitude.ToString();
label2.Text = pot.Latitude.ToString();
}
}
希望这会对你有帮助。
Hope this will help you.
这篇关于使用线程重新获取代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文