public int Run(WindowCore mainWindow = null) { Action destroyHandler = () => { MessageHelpers.PostQuitMessage(); }; if (mainWindow != null) { mainWindow.Destroyed += destroyHandler; } var res = this.RunCore(); // Technically, this can be avoided by setting the handler to auto disconnect. // However, this helps keep the mainWindow alive, and use this instead of // GC.KeepAlive pattern. if (mainWindow != null) { mainWindow.Destroyed -= destroyHandler; } return(res); }
public void Exit() { MessageHelpers.PostQuitMessage(); }