如何一个接一个地开始时间C# [英] How to start times one after one C#
本文介绍了如何一个接一个地开始时间C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
does any one can help me in this problem: I have 2 timers in a form C#, I want this: when form is loaded, one timer to start counting down from 15 to 0, after first timer finished, then the second timer start same. I write code but when the form is loaded both timer starts.
我尝试了什么:
:
What I have tried:
in a form_load:
timer1.Interval = 1000;
timer2.Interval = 1000;
timer1.Start();
timer2.Start();
计时器一:
timer one:
time--;
if (time== 0)
timer1.Stop();
lblKoha.Text = koha.ToString();
计时器2
timer two
time2--;
if (time2== 0)
timer2.Stop();
我声明:
I declare:
private int time= 15;
private int time2= 15;
推荐答案
您好:
在您拥有的负载中:
Hello:
In the load you have:
timer1.Interval = 1000;
timer2.Interval = 1000;
timer1.Start();
timer2.Start();
即:你同时启动两个计时器。
如果你只想要启动timer2然后当timer1在加载中完成时你必须禁止 timer2.Start()
,并在timer1中更改
that is: you start the two timer at the same time.
If you only want to start the timer2 when then timer1 finish in the load you have to suppress the timer2.Start()
, and in the timer1 change
if (time== 0)
timer1.Stop();
for
for
if (time== 0) {
timer1.Stop();
timer2.Start();
}
timer1.Interval = 1000;
timer2.Interval = 1000;
timer1.Start();
//timer2.Start();
time--;
if (time== 0)
{
timer1.Stop();
timer2.Start();
}
lblKoha.Text = koha.ToString();
这篇关于如何一个接一个地开始时间C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文