static StatusController() { current = new Status(); }
private void AppController_OnStatusChange(Status obj) { this.UpdateStatus(obj); }
/// <summary> /// 重置状态 /// </summary> public static void Reset() { if (null != OnStatusChange) { try { RWLock.EnterWriteLock(); current = new Status(); } finally { RWLock.ExitWriteLock(); } UpdateUIStatus(); } }
public void UpdateStatus(Status status) { this.tlsDownloadNum.Text = "已抓取:" + status.DownloadNum + "张"; this.tslThreadNum.Text = "线程数:" + status.ThreadNum.ToString(); this.tslState.Text = "状态:" + status.State.ToString(); switch (status.State) { case State.运行中: tbSetting.Enabled = btnStart.Enabled = false; btnStop.Enabled = true; break; case State.正在取消: tbSetting.Enabled = btnStart.Enabled = false; btnStop.Enabled = false; break; default: tbSetting.Enabled = btnStart.Enabled = true; btnStop.Enabled = false; tmConsume.Stop(); break; } }