private void OnDownloadHtmlCompleted(object sender, DownloadHtmlCompletedEventArgs e) { string html = e.Html; progressBar1.Value = progressBar1.Maximum; progressBar1.Style = ProgressBarStyle.Blocks; button1.Enabled = true; button2.Enabled = true; }
public void DownloadHtmlAsync(Uri address) // 外部调用的入口 { new DownloadHtmlCallback((Uri uri, AsyncOperation op) => // 下载函数 { string html = InternalDownload(uri); DownloadHtmlCompletedEventArgs e = new DownloadHtmlCompletedEventArgs(null, false, html); op.PostOperationCompleted(DownloadHtmlCompletedCallback, e); // 下载完成后,调用complete函数,关联comple函数和e }).BeginInvoke(address, AsyncOperationManager.CreateOperation(null), null, null); // 调用async下载函数,关联async函数和和asyncOperation }