private void Crawler_CrawlerStopped(MyCrawler obj) { Action action = () => labelStart.Text = "爬虫已停止"; if (this.InvokeRequired) { this.Invoke(action); } else { action(); } }
private void Crawler_PageDownloaded(MyCrawler 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(); } }