我試圖在實時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