@@ -114,27 +114,35 @@ private void Initialize()
114
114
115
115
lock ( _accessLock )
116
116
{
117
- if ( Initialized )
118
- return ;
119
- _threadManager = new ThreadManager ( ) ;
120
- _threadManager . NewLog += ( o , e ) => Globals . Logs . Add ( e , false ) ;
121
- _logsStorage = new LogsStorage ( ) ;
122
- _lastActions = new ObservableCollection < IProfileAction > ( ) ;
123
- InitializeApplicationWatcher ( ) ;
124
- LoadSettings ( ) ;
125
- Globals . Logs . Add ( "Initializing..." , false ) ;
126
-
127
- if ( Settings . CheckForNewVersion )
128
- CheckForNewVersion ( ) ;
129
- InitializeDisplayManager ( ) ;
130
- InitializeAudioManager ( ) ;
131
- InitializeTrayMenuHelper ( ) ;
132
- Globals . Instance . SaveSettings ( ) ;
133
- CreateRelayCommands ( ) ;
134
- ShowView = ! Settings . StartMinimizedToTray ;
135
- Initialized = true ;
136
- Globals . Logs . Add ( "Initialized" , false ) ;
137
- Start ( ) ;
117
+ try
118
+ {
119
+ if ( Initialized )
120
+ return ;
121
+ _threadManager = new ThreadManager ( ) ;
122
+ _threadManager . NewLog += ( o , e ) => Globals . Logs . Add ( e , false ) ;
123
+ _logsStorage = new LogsStorage ( ) ;
124
+ _lastActions = new ObservableCollection < IProfileAction > ( ) ;
125
+ InitializeApplicationWatcher ( ) ;
126
+ LoadSettings ( ) ;
127
+ Globals . Logs . Add ( "Initializing..." , false ) ;
128
+
129
+ if ( Settings . CheckForNewVersion )
130
+ CheckForNewVersion ( ) ;
131
+ InitializeDisplayManager ( ) ;
132
+ InitializeAudioManager ( ) ;
133
+ InitializeTrayMenuHelper ( ) ;
134
+ Globals . Instance . SaveSettings ( ) ;
135
+ CreateRelayCommands ( ) ;
136
+ ShowView = ! Settings . StartMinimizedToTray ;
137
+ Initialized = true ;
138
+ Globals . Logs . Add ( "Initialized" , false ) ;
139
+ Start ( ) ;
140
+ }
141
+ catch ( Exception ex )
142
+ {
143
+ Globals . Logs . AddException ( ex ) ;
144
+ throw ex ;
145
+ }
138
146
}
139
147
}
140
148
@@ -148,11 +156,18 @@ private void InitializeApplicationWatcher()
148
156
149
157
private void ApplicationWatcher_ApplicationChanged ( object sender , ApplicationChangedEventArgs e )
150
158
{
151
- Globals . Logs . Add ( $ "Application { e . Application } changed: { e . ChangedType } ", false ) ;
152
- CurrentApplication = e . Application ;
153
- UpdateCurrentProfile ( e . Application , e . ChangedType ) ;
154
- if ( e . ChangedType == ApplicationChangedType . Closed )
155
- CurrentApplication = null ;
159
+ try
160
+ {
161
+ Globals . Logs . Add ( $ "Application { e . Application } changed: { e . ChangedType } ", false ) ;
162
+ CurrentApplication = e . Application ;
163
+ UpdateCurrentProfile ( e . Application , e . ChangedType ) ;
164
+ if ( e . ChangedType == ApplicationChangedType . Closed )
165
+ CurrentApplication = null ;
166
+ }
167
+ catch ( Exception ex )
168
+ {
169
+ Globals . Logs . AddException ( ex ) ;
170
+ }
156
171
}
157
172
158
173
private void ApplicationWatcher_NewLog ( object sender , string e )
@@ -336,13 +351,9 @@ private void LoadSettings()
336
351
337
352
Settings . PropertyChanged += Settings_PropertyChanged ;
338
353
339
- ApplicationProfileAssigments_CollectionChanged (
340
- Settings . ApplicationProfileAssignments , new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Add , Settings . ApplicationProfileAssignments . ToList ( ) ) ) ;
341
-
354
+ ApplicationProfileAssigments_CollectionChanged ( Settings . ApplicationProfileAssignments , new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Add , Settings . ApplicationProfileAssignments . ToList ( ) ) ) ;
342
355
ApplicationProfiles_CollectionChanged ( Settings . ApplicationProfiles , new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Add , Settings . ApplicationProfiles . ToList ( ) ) ) ;
343
-
344
-
345
-
356
+ ActionShortcuts_CollectionChanged ( Settings . ActionShortcuts , new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Add , Settings . ActionShortcuts . ToList ( ) ) ) ;
346
357
Monitors_CollectionChanged ( Settings . Displays , new NotifyCollectionChangedEventArgs ( NotifyCollectionChangedAction . Add , Settings . Displays . ToList ( ) ) ) ;
347
358
348
359
0 commit comments