/// <summary> /// 循环结构 /// </summary> public void Runtime(object sender) { count++; Info?.Invoke("计数:" + count.ToString()); WorkCode?.Invoke(); if (count == 1000) { EndCode?.Invoke(); } }
/// <summary> /// 循环结构 /// </summary> public void Runtime() { for (int i = 0; i < 1000; i++) { if (stop)//退出 { StopCode?.Invoke(); return; } if (on_off)//运行和暂停切换 { ma = new ManualResetEvent(false); ma.WaitOne(); } Info?.Invoke("计数:" + i.ToString()); WorkCode?.Invoke(); Thread.Sleep(500); } EndCode?.Invoke(); }