static bool ConsoleEventCallback(int eventType) { if (eventType == 2) { if (DxInput.IsLoaded) { DxInput.Unload(); } } return(false); }
public static int animDelay = 250; //Ticks to secs static void Main(string[] args) { handler = new ConsoleEventDelegate(ConsoleEventCallback); SetConsoleCtrlHandler(handler, true); var CoreCount = System.Environment.ProcessorCount / 2; var maxThreads = (Environment.ProcessorCount * CoreCount); DxInput.initInput(); var sw = new Stopwatch(); Console.Title = $"Max concurrent threads {maxThreads}"; askMode(); running = true; new Task(() => { ScreenDrawer.printDebug(); }).Start(); while (running) { sw.Restart(); if (!Program.paused) { currSkill.takeAction(); } sw.Stop(); var ticks = sw.ElapsedTicks; if (ticks < 3000) { avgTicks.Add(ticks); avgTicks.Sort(); var Ispaused = Program.paused ? "paused" : "running"; Console.Title = $"{currSkill.getSkillName()} - {avgTicks.Average().ToString("#,##0")}Avg. {avgTicks.First()}min {avgTicks.Last()}max {animChar[animCount]} {Ispaused}"; if (avgTicks.Count > 20000) { avgTicks = new List <long>(); } } if (lastAnimTick.AddMilliseconds(animDelay) < DateTime.Now) { lastAnimTick = DateTime.Now; animCount += 1; if (animCount >= animChar.Length) { animCount = 0; } } } DxInput.Unload(); Console.ReadKey(); }