public AutoPlayScriptManager(Form1 form) { scripts.Add(new AutoPlay律山紫vs皮皮马31626up37952(bh3window)); scripts.Add(new AutoPlay山粉蓝vs月轮37760非up31146(bh3window)); currentScript = scripts[0]; this.form = form; mainThread = new Thread(new ThreadStart(() => { while (this.running) { if (!bh3window.CheckWindow()) { continue; } bool isStart = bh3window.IsStart(); Thread.Sleep(10); if (isStart) { ScriptStartEvent(); currentScript.Start(); // 阻塞,等待脚本打完 while (currentScript.running) { ; } } else { ScriptStopEvent(); } } })); mainThread.Start(); new Thread(new ThreadStart(CheckRunning)).Start(); }
public AutoPlayScriptManager(Form1 form) { scripts.Add(new AutoPlay鬼圣轮vs皮皮马31733up38080(bh3window)); scripts.Add(new AutoPlay墨炎真VS冰箱31680up38016(bh3window)); scripts.Add(new AutoPlay鬼圣迅vs贝贝龙31573up37888(bh3window)); scripts.Add(new AutoPlay律山紫vs皮皮马31626up37952(bh3window)); scripts.Add(new AutoPlay山粉蓝vs月轮37760非up31466(bh3window)); currentScript = scripts[0]; this.form = form; mainThread = new Thread(new ThreadStart(() => { lock (lockObject) { while (running) { Thread.Sleep(10); if (!bh3window.CheckWindow()) { continue; } bool isStart = bh3window.IsStart(); if (isStart) { Console.WriteLine("start"); ScriptStartEvent(); // 阻塞,等待脚本打完 currentScript.Start(); while (currentScript.running) { Thread.Sleep(100); } } else { ScriptStopEvent(); } } } })); mainThread.Start(); checkRunThread = new Thread(new ThreadStart(CheckRunning)); checkRunThread.Start(); }