Skip to content

Commit d6541b6

Browse files
committed
fix: #775
1 parent aa1f375 commit d6541b6

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

Ui/View/Host/TabWindowViewModel.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,29 +259,28 @@ public RelayCommand CmdGoMaximizeF11
259259
}
260260

261261

262-
private bool _canCmdClose = true;
262+
private object _canCmdClose = new object();
263263
private RelayCommand? _cmdCloseAll;
264264
public RelayCommand CmdCloseAll
265265
{
266266
get
267267
{
268268
return _cmdCloseAll ??= new RelayCommand((o) =>
269269
{
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)
273272
{
274-
_canCmdClose = false;
273+
if (this.Items.Count <= 0 || App.ExitingFlag != false) return;
275274
if (IoC.Get<ConfigurationService>().General.ConfirmBeforeClosingSession == true
276275
&& false == MessageBoxHelper.Confirm(IoC.Translate("Are you sure you want to close the connection?"), ownerViewModel: this))
277276
{
278-
return;
279277
}
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+
}
285284
}
286285
});
287286
}
@@ -294,9 +293,8 @@ public RelayCommand CmdClose
294293
{
295294
return _cmdClose ??= new RelayCommand((o) =>
296295
{
297-
if (_canCmdClose)
296+
lock (_canCmdClose)
298297
{
299-
_canCmdClose = false;
300298
if (IoC.Get<ConfigurationService>().General.ConfirmBeforeClosingSession == true
301299
&& App.ExitingFlag == false
302300
&& false == MessageBoxHelper.Confirm(IoC.Translate("Are you sure you want to close the connection?"), ownerViewModel: this))
@@ -319,8 +317,6 @@ public RelayCommand CmdClose
319317
IoC.Get<SessionControlService>().CloseProtocolHostAsync(host.ConnectionId);
320318
}
321319
}
322-
323-
_canCmdClose = true;
324320
}
325321
}, o => this.SelectedItem != null);
326322
}

0 commit comments

Comments
 (0)