public InterfaceCompositor(IDisplayEngine engine) { Logging.Log("Initializing GUIFooter..."); Footer = new GUIFooter(); Logging.Log("GUIFooter initialized"); new Task(Footer.Update).Start(); Engine = engine; UpdateRegion(); //because the program may run before the first UpdateRegion() occured and that will cause bugs new Task(() => { while(true) { UpdateRegion(); Thread.Sleep(200); } }).Start(); Engine.Navigate("home"); //IDisplayEngine.Navigate() has to be non-blocking to prevent the UI from freezing up ConsoleKeyInfo key; while(true) { key = Console.ReadKey (true); if(!(Footer.Keypress(key, ref Engine) || Engine.Keypress(key))) { Footer.Keypress(key, ref Engine, true); } } }
public InterfaceCompositor(IDisplayEngine engine) { Footer = new GUIFooter(); new Task(Footer.Update).Start(); _engine = engine; UpdateRegion(); //because the program may run before the first UpdateRegion() occured and that will cause bugs new Task(() => { while(true) { UpdateRegion(); Thread.Sleep(200); } }).Start(); new Task(() => _engine.Navigate("home")).Start(); //new Task since IDisplayEngine.Navigate() could be blocking, thus hindering keypresses from being handled ConsoleKeyInfo key; while((key = Console.ReadKey(true)) != null) { if(!(Footer.Keypress(key) || _engine.Keypress(key))) { Footer.Keypress(key, true); } } }