@@ -259,29 +259,28 @@ public RelayCommand CmdGoMaximizeF11
259
259
}
260
260
261
261
262
- private bool _canCmdClose = true ;
262
+ private object _canCmdClose = new object ( ) ;
263
263
private RelayCommand ? _cmdCloseAll ;
264
264
public RelayCommand CmdCloseAll
265
265
{
266
266
get
267
267
{
268
268
return _cmdCloseAll ??= new RelayCommand ( ( o ) =>
269
269
{
270
- if ( _canCmdClose
271
- && this . Items . Count > 0
272
- && App . ExitingFlag == false )
270
+ if ( this . Items . Count <= 0 || App . ExitingFlag != false ) return ;
271
+ lock ( _canCmdClose )
273
272
{
274
- _canCmdClose = false ;
273
+ if ( this . Items . Count <= 0 || App . ExitingFlag != false ) return ;
275
274
if ( IoC . Get < ConfigurationService > ( ) . General . ConfirmBeforeClosingSession == true
276
275
&& false == MessageBoxHelper . Confirm ( IoC . Translate ( "Are you sure you want to close the connection?" ) , ownerViewModel : this ) )
277
276
{
278
- return ;
279
277
}
280
-
281
- IoC . Get < SessionControlService > ( ) . CloseProtocolHostAsync (
282
- Items
283
- . Select ( x => x . Content . ConnectionId ) . ToArray ( ) ) ;
284
- _canCmdClose = true ;
278
+ else
279
+ {
280
+ IoC . Get < SessionControlService > ( ) . CloseProtocolHostAsync (
281
+ Items
282
+ . Select ( x => x . Content . ConnectionId ) . ToArray ( ) ) ;
283
+ }
285
284
}
286
285
} ) ;
287
286
}
@@ -294,9 +293,8 @@ public RelayCommand CmdClose
294
293
{
295
294
return _cmdClose ??= new RelayCommand ( ( o ) =>
296
295
{
297
- if ( _canCmdClose )
296
+ lock ( _canCmdClose )
298
297
{
299
- _canCmdClose = false ;
300
298
if ( IoC . Get < ConfigurationService > ( ) . General . ConfirmBeforeClosingSession == true
301
299
&& App . ExitingFlag == false
302
300
&& false == MessageBoxHelper . Confirm ( IoC . Translate ( "Are you sure you want to close the connection?" ) , ownerViewModel : this ) )
@@ -319,8 +317,6 @@ public RelayCommand CmdClose
319
317
IoC . Get < SessionControlService > ( ) . CloseProtocolHostAsync ( host . ConnectionId ) ;
320
318
}
321
319
}
322
-
323
- _canCmdClose = true ;
324
320
}
325
321
} , o => this . SelectedItem != null ) ;
326
322
}
0 commit comments