public CardRenderWindow(CmdCards launcherCommand, CommandViewModel vm) { Command = launcherCommand; Game = new CardGame(this); InitializeComponent(); stopwatch = new Stopwatch(); renderTick = new DispatcherTimer(); renderTick.Interval = TimeSpan.FromMilliseconds(10); renderTick.Tick += MainLoop; }
public CardRenderWindow LaunchCardWindow(CmdCards cmd) { CardRenderWindow res = null; cardWindowThread = new Thread(() => { CardRenderWindow crw = new CardRenderWindow(cmd, this); res = crw; crw.Closed += (sender, e) => { crw.Dispatcher.InvokeShutdown(); cmd.ReleaseInput(); }; crw.Show(); System.Windows.Threading.Dispatcher.Run(); }); cardWindowThread.SetApartmentState(ApartmentState.STA); cardWindowThread.Start(); Window.Dispatcher.Invoke(PrintingFormatted, "&e&*Starting Window...\r"); while (res == null) // sorta hacky workaround { Thread.Sleep(1); // prevent excessive memory use } return res; }