private TaskbarPanel CreateTaskbarPanel(MainViewModel mainViewModel, IUiHelper uiHelper) { try { var taskbarPanel = new TaskbarPanel(_mainWindowReadyLatch, new NLogLogger("TaskbarPanel"), mainViewModel, uiHelper); taskbarPanel.InitializeButtons(); return(taskbarPanel); } catch (Exception ex) { _log.ErrorException("Failed to initialize taskbar module", ex); uiHelper.ShowMessage(ex.ToString()); uiHelper.IgnoreException(_instanceMutex.ReleaseMutex); _instanceMutex = null; Current.Shutdown(); Environment.Exit(0); } return(null); }
public void Stop() { _uiHelper.IgnoreException(() => _explorerProcess.Exited -= OnExplorerCrash); }
private static void Main(string[] args) { var startTicks = Environment.TickCount; var currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += ExceptionHandler; bool createdNew; _instanceMutex = new Mutex(true, @"AppDirect.WindowsClient Browser Mutex", out createdNew); if (!createdNew) { Log.Info("Instance already exists, exit."); _instanceMutex = null; Environment.Exit(0); } try { BrowserObject.Initialize(); } catch (Exception e) { Log.ErrorException("Failed to initialize the browser", e); MessageBox.Show(String.Format(Resources.Failed_to_initialize_browser_error_message, e.Message)); return; } var api = new BrowsersManagerApi(BrowserWindowsManager, UiHelper); var apiStarter = new IpcMainWindowStarter(api); var mainAppClient = new MainApplicationServiceClient(new MainApplicationClientServiceStarter(), UiHelper, new NLogLogger("MainApplicationServiceClient")); var appDirectClientProcessWatcher = new ProcessWatcher(_mainApplicationName, new AbstractProcess(_mainApplicationName, new NLogLogger("BrowserMainProcess")), Log); var sessionKeeper = new SessionKeeper(mainAppClient, BrowserWindowsManager, BrowserWindowsBuilder, new NLogLogger("Browser.SessionKeeper"), UiHelper); try { var app = new App(); app.InitializeComponent(); UiHelper.IgnoreException(sessionKeeper.Start); bool hadStartException = false; try { apiStarter.Start(); } catch (Exception e) { Log.ErrorException("Failed to start server communication", e); hadStartException = true; } UiHelper.IgnoreException(appDirectClientProcessWatcher.Start); if (!hadStartException) { var wasInitialized = InitializeClient(mainAppClient); if (wasInitialized) { var timeElapsed = Environment.TickCount - startTicks; Log.Warn("BrowserManager startup completed in " + timeElapsed + "ms."); app.Run(); } } } finally { UiHelper.IgnoreException(apiStarter.Stop); UiHelper.IgnoreException(appDirectClientProcessWatcher.Stop); UiHelper.IgnoreException(sessionKeeper.Stop); UiHelper.IgnoreException(BrowserObject.Unload); UiHelper.IgnoreException(_instanceMutex.ReleaseMutex); } }
private TaskbarPanel CreateTaskbarPanel(MainViewModel mainViewModel, IUiHelper uiHelper) { try { var taskbarPanel = new TaskbarPanel(_mainWindowReadyLatch, new NLogLogger("TaskbarPanel"), mainViewModel, uiHelper); taskbarPanel.InitializeButtons(); return taskbarPanel; } catch (Exception ex) { _log.ErrorException("Failed to initialize taskbar module", ex); uiHelper.ShowMessage(ex.ToString()); uiHelper.IgnoreException(_instanceMutex.ReleaseMutex); _instanceMutex = null; Current.Shutdown(); Environment.Exit(0); } return null; }