private static void DoWork(object data) { RefreshThread refresher = (RefreshThread)data; try { List <Proxy> pList = refresher.proxyList; foreach (Proxy proxy in pList) { refresher.Description = proxy.IpAndPort + "开始刷新..."; try { Refresh(refresher, proxy); RefreshForm fm = (RefreshForm)Application.OpenForms["RefreshForm"]; if (null != fm) { fm.UpdateDataGrid(); } Thread.Sleep(refresher.sleepTime * 1000); } catch (ThreadAbortException) { } catch (Exception) { } finally { refresher.TotalCount++; } refresher.Status = refresher.thread.ThreadState.ToString(); } refresher.Status = "Completed"; } catch (Exception ex) { // 线程被放弃 refresher.Status = "Completed"; Console.WriteLine(ex.Message); //WriteException(ex); } finally { refresher.OnCompleted(); } }