private void Crawler_PageDownloaded(crawler crawler, string url, string info) { var pageInfo = new { Index = resultBindingSource.Count + 1, URL = url, Status = info }; Action action = () => { resultBindingSource.Add(pageInfo); }; if (this.InvokeRequired) { this.Invoke(action); } else { action(); } }
private void Crawler_CrawlerStopped(crawler obj) { sw.Stop(); Action action = () => lblInfo.Text = "爬虫已停止...平均运行时间:" + sw.Elapsed.TotalSeconds / crawler.DownloadedPages.Count + "s"; if (this.InvokeRequired) { this.Invoke(action); } else { action(); } }