public void Launch(INotifications notifications, AlertModel alert) { _alerts = AlertsFactory.GetAlerts().ToList(); AlertsFactory.AddAlert(alert); _alerts.Add(alert); Thread windowThread = new Thread(new ThreadStart(() => { try { SettingsModel settings = SettingsFactory.GetSettings(Configuration.Current.SettingsFilePath); TriggerAlerts(notifications, settings, alert); if (_app == null) { _app = new App(Configuration.Current.SettingsFilePath, _alerts); _app.EventAggregator.GetEvent <AlertRemovedEvent>().Subscribe(AlertRemovedEvent_Handler); _app.ShellView.Title = Configuration.Current.Title; _app.ShellView.Closed += (sender, args) => { _app = null; }; } _app.InvokeAlertAddedEvent(alert); _app.Run(); } catch (InvalidOperationException ex) { Logger.LogException(ex); } })); windowThread.SetApartmentState(ApartmentState.STA); windowThread.CurrentCulture = CultureInfo.InvariantCulture; windowThread.CurrentUICulture = CultureInfo.InvariantCulture; windowThread.Start(); }
private void AlertRemovedEvent_Handler(AlertModel alert) { AlertsFactory.RemoveAlert(alert); }