我试图在实时16秒内停止计时器,但我不知道我该怎么做。如何以秒实时停止计时器c#?
我做了这个小例子:当picturebox1与picturebox2相交时,这个动作激活一个计时器,并且这个计时器必须在16秒内实时显示picturebox3并且在停止它之后(计时器)(并且picturebox3不会显示)。
(对不起,我的英语,但西班牙语的StackOverflow没有太多的信息)。
我使用Windows窗体和C#
private void timer2_Tick(object sender, EventArgs e)
{
pictureBox7.Hide();
if ((pictureBox3.Bounds.IntersectsWith(pictureBox2.Bounds) && pictureBox2.Visible) || (pictureBox5.Bounds.IntersectsWith(pictureBox2.Bounds) && pictureBox2.Visible))
{
puntaje++;
this.Text = "Puntaje: " + puntaje;
if (puntaje % 5 == 0)
{
timer3.Enabled=true;
//This is the part where i want set down the timer3, timer 2 is on
}
}
您的计时器是否需要非常准确?正好在16.0000000000秒?如果你不那么精确,那么请看'System.Timers.Timer.Elapsed'事件(https://msdn.microsoft.com/en-us/library/system.timers.timer.elapse(v=vs) .110).aspx) – Svek