public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
this.backgroundWorker1.RunWorkerAsync();
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("各种Info快来下载吧!");
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 30000; i < 30030; i++)
{
WebClient client = new WebClient();
try
{
client.DownloadFile(@"http://job.cnblogs.com/offer/" + i + "/", @"E:html" + i + ".html");
}
catch { }
}
//Action是委托
Action action = new Action(msg);
this.Invoke(action);
}
private void msg()
{
MessageBox.Show("下载完成!");
}
}