private void time_counter_Tick(object sender, EventArgs e)
{
secs += 1;
if (secs == 60)
{
secs = 0;
mins += 1;
if (mins == 60)
{
mins = 0;
hrs += 1;
}
}
time_counter_lbl.Text = getCurrentTimeString();
}
private void startTheCounter()
{
secs = mins = hrs = 0;
time_counter.Start();
time_lbl.Visible = true;
time_counter_lbl.Visible = true;
}
private void stopTheCounter()
{
time_counter.Stop();
}
private string getCurrentTimeString()
{
string sec, min, hr;
sec = min = hr = "";
if (secs < 10)
sec = "0" + secs.ToString();
else
sec = secs.ToString();
if (mins < 10)
min = "0" + mins.ToString();
else
min = mins.ToString();
if (hrs < 10)
hr = "0" + hrs.ToString();
else
hr = hrs.ToString();
return hr + ":" + min + ":" + sec;
}
在我的应用程序中,有 db 调用。同时我想显示经过的时间。但是时间标签没有更新。请帮助我,如何在单独的线程中解决此问题以解决此问题。