关于线程的问题?请问一下,我在线程结束后,自动关闭窗体,但是我就是弄不清楚在关闭窗体事件应该写在那里,
public partial class Form1 : Form
{
Thread a;
private int p = 0;
delegate void ChangeValue(int value);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
a = new Thread(new ThreadStart(all_count));
a.Start();
}
private void all_count()
{
for (int i = 0; i < 1000; i++)
{
Thread.Sleep(1);
p = p + 1;
progressBar1.BeginInvoke(new ChangeValue(Change1), (progressBar1.Value + 1) % 100);
}
a.Abort();
}
private void Change1(int value)
{
progressBar1.Value = value;