private void Crawler_CrawlerStopped(crawler obj) { Action action = () => lblInfo.Text = "爬虫已停止"; if (this.InvokeRequired) { this.Invoke(action); } else { action(); } }
private void Crawler_PageDownloaded(crawler crawler, string url, string status) { var pageInfo = new { Index = resultBindingSource.Count + 1, URL = url, Status = status }; Action action = () => { resultBindingSource.Add(pageInfo); }; if (this.InvokeRequired) { this.Invoke(action); } else { action(); } }