2
這是我的,爲什麼我的計時器不停止? 我不知道我在做什麼錯。 我對C#相當陌生,我試圖讓它成爲我的啓動畫面隱藏(form1)和我的程序啓動(samptool),但是我的程序啓動但啓動屏幕保持,定時器重置而不是停止。應用程序每6.5秒會在新窗口中打開。C#計時器不停止?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Timers;
namespace SplashScreen.cs
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Interval = 250;
timer2.Interval = 6500;
timer1.Start();
timer2.Start();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
this.progressBar1.Increment(5);
}
private void timer2_Tick(object sender, EventArgs e)
{
SampTool w = new SampTool();
Form1 m = new Form1();
timer1.Enabled = false;
timer1.Stop();
timer2.Enabled = false;
timer2.Stop();
m.Hide();
w.Show();
}
}
}