【发布时间】:2015-03-28 14:27:18
【问题描述】:
我的 Windows 窗体上有一个文本框,我想显示我的过程所用的时间,但我没有看到文本框中有任何时间计数。下面是我的代码
public partial class Form1 : System.Windows.Forms.Form
{
private Stopwatch watch = new Stopwatch()l
private void btn_RashadSL()
{
watch.Start();
//lots of code here that typically takes around 15 - 20 minutes to complete
}
private void timer_Tick(object sender, EventArgs e)
{
textbox1.Text = watch.Elapsed.Seconds.ToString();
}
}
【问题讨论】:
-
还有一点需要注意的是要小心避免跨线程操作。