C#windows程序按钮

来源:百度知道 编辑:UC知道 时间:2024/05/23 01:22:04
private void button1_Click(object sender, EventArgs e)
{
this.button1.Enabled = false; //变灰了
Spider m_spider = new Spider();
m_spider.OutputPath = textBox2.Text;
int threads = int.Parse(textBox3.Text);
if (threads < 1)
threads = 1;
Uri URL = new Uri(textBox1.Text);

try
{
m_spider.Start(URL, threads, this);
}
catch (UriFormatException ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
return;
}

}
我想让这个按钮当所有线程都执行完毕的时候变回可以点击的状态应该怎么干?

private void button1_Click(object sender, EventArgs e)
{
this.button1.Enabled = false; //变灰了
Spider m_spider = new Spider();
m_spider.OutputPath = textBox2.Text;
int threads = int.Parse(textBox3.Text);
if (threads < 1)
threads = 1;
Uri URL = new Uri(textBox1.Text);

try
{
m_spider.Start(URL, threads, this);
}
catch (UriFormatException ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
return;
} finally{
this.button1.Enabled = true; //再变回来不就行了
}

}