@@ -141,29 +141,38 @@ public void Launch(INotifications notifications, AlertModel alert)
141141
142142 Thread windowThread = new Thread ( new ThreadStart ( ( ) =>
143143 {
144- SettingsModel settings = SettingsFactory . GetSettings ( Configuration . Current . SettingsFilePath ) ;
145-
146- TriggerAlerts ( notifications , settings , alert ) ;
147-
148- if ( _app == null )
144+ try
149145 {
150- _app = new App ( Configuration . Current . SettingsFilePath , _alerts ) ;
146+ _logger . Log ( "Triggering" ) ;
151147
152- _app . EventAggregator . GetEvent < AlertRemovedEvent > ( ) . Subscribe ( AlertRemovedEvent_Handler ) ;
148+ SettingsModel settings = SettingsFactory . GetSettings ( Configuration . Current . SettingsFilePath ) ;
153149
154- _app . ShellView . Title = Configuration . Current . Title ;
150+ TriggerAlerts ( notifications , settings , alert ) ;
155151
156- _app . ShellView . Closed += ( sender , args ) =>
152+ if ( _app == null )
157153 {
158- _app . EventAggregator . GetEvent < AlertRemovedEvent > ( ) . Unsubscribe ( AlertRemovedEvent_Handler ) ;
154+ _app = new App ( Configuration . Current . SettingsFilePath , _alerts ) ;
159155
160- _app = null ;
161- } ;
162- }
156+ _app . EventAggregator . GetEvent < AlertRemovedEvent > ( ) . Subscribe ( AlertRemovedEvent_Handler ) ;
157+
158+ _app . ShellView . Title = Configuration . Current . Title ;
159+
160+ _app . ShellView . Closed += ( sender , args ) =>
161+ {
162+ _app . EventAggregator . GetEvent < AlertRemovedEvent > ( ) . Unsubscribe ( AlertRemovedEvent_Handler ) ;
163163
164- _app . InvokeAlertAddedEvent ( alert ) ;
164+ _app = null ;
165+ } ;
166+ }
165167
166- _app . Run ( ) ;
168+ _app . InvokeAlertAddedEvent ( alert ) ;
169+
170+ _app . Run ( ) ;
171+ }
172+ catch ( InvalidOperationException ex )
173+ {
174+ _logger . Log ( ex ) ;
175+ }
167176 } ) ) ;
168177
169178 windowThread . SetApartmentState ( ApartmentState . STA ) ;
0 commit comments