void Init() { if (delay <= 0) { //if(mode!=Mode.Timer)throw new Exception("delay must be more then 0"); while (true) { int t = KeyboardUpdate(); if (t != -1) { game.Event(t); } } } DateTime time = DateTime.Now; while (true) { int t = KeyboardUpdate(); if (mode == Mode.Delay) { game.Event(t); System.Threading.Thread.Sleep(delay); } else if (mode == Mode.Multithreaded) { if (t != -1 && threadMarker) { game.Event_set(t); } } else if (mode == Mode.Timer) { if (t == -1) { double delta = -time.Subtract(DateTime.Now).TotalMilliseconds; if (delta > delay) { time = DateTime.Now; game.Event(t); } } else { time = DateTime.Now; game.Event(t); } } else if (mode == Mode.Multithreaded_sim) { if (t == -1) { double delta = -time.Subtract(DateTime.Now).TotalMilliseconds; if (delta > delay) { time = DateTime.Now; game.Event(t); } } else { game.Event_set(t); } } } }