日期:2014-05-16 浏览次数:20501 次
private Thread timeThread;
private DateTime dt;
public void refreshSatus()
{
while (true)
{
runTime_LB.Text = dt.GetDateTimeFormats('t')[0].ToString();
dt.AddSeconds(1);
Thread.Sleep(1);
}
}
private void startButton_Click(object sender, EventArgs e)
{
timeThread = new Thread(new ThreadStart(refreshSatus));
timeThread.Start();
startButton.Enabled = false;
stopButton.Enabled = true;
}
private void stopButton_Click(object sender, EventArgs e)
{
timeThread.Abort();
stopButton.Enabled = false;
stopButton.Enabled = false;
}
while (true)
{
Invoke((MethodInvoker)delegate{ runTime_LB.Text = dt.GetDateTimeFormats('t')[0].ToString();});
dt.AddSeconds(1);
Thread.Sleep(1);
}