日期:2014-05-18 浏览次数:20443 次
public void SaveUrlPics(string url, string path, Random ran) { WebClient wc = new WebClient(); string address = path + "\\" + CreateRandomCode(8) + GetSuffix(path); try { //在这里我想把当前线程等待 wc.DownloadFile(url, address); wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted); } catch (Exception ex) { ListUrl.writeLog(ex.Message); } finally { wc.Dispose(); } } void wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { //下载完成后,放走线程。 }