diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index f13f467..19c3ded 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -22,9 +22,10 @@
enable
true
false
+ <_SkipUpgradeNetAnalyzersNuGetWarning >true
- 1.1.4
+ 1.1.5
@@ -53,15 +54,15 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/WirePeep.Common/WirePeep.Common.csproj b/src/WirePeep.Common/WirePeep.Common.csproj
index c89280f..346c896 100644
--- a/src/WirePeep.Common/WirePeep.Common.csproj
+++ b/src/WirePeep.Common/WirePeep.Common.csproj
@@ -9,8 +9,8 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/src/WirePeep/MainWindow.xaml.cs b/src/WirePeep/MainWindow.xaml.cs
index 2c87bb1..f50578a 100644
--- a/src/WirePeep/MainWindow.xaml.cs
+++ b/src/WirePeep/MainWindow.xaml.cs
@@ -45,7 +45,7 @@ public sealed partial class MainWindow : ExtendedWindow, IDisposable
private StateManager? stateManager;
private Timer? backgroundTimer;
private int updatingLock;
- private bool closing;
+ private ClosingState closingState;
private ConnectionState? simulateConnection;
private DataGrid? selectedGrid;
private Logger? logger;
@@ -61,7 +61,7 @@ public MainWindow()
this.InitializeComponent();
this.statusRows = (StatusRowCollection)this.Resources["StatusRows"];
- this.statusRowMap = new Dictionary();
+ this.statusRowMap = [];
this.logRows = (LogRowCollection)this.Resources["LogRows"];
this.failedPeerGroupToLogRowMap = new Dictionary(this.statusRowMap.Comparer);
@@ -75,6 +75,17 @@ public MainWindow()
#endregion
+ #region Private Enums
+
+ private enum ClosingState
+ {
+ None,
+ Requested,
+ Confirmed,
+ }
+
+ #endregion
+
#region Internal Properties
internal bool StartMinimized { get; set; }
@@ -143,7 +154,7 @@ internal void SaveNonWindowSettings()
private static void CopyToClipboard(DataGrid source, bool copyRow)
{
- IList copyCells = copyRow ? source.SelectedCells : new[] { source.CurrentCell };
+ IList copyCells = copyRow ? source.SelectedCells : [source.CurrentCell];
StringBuilder sb = new();
foreach (DataGridCellInfo cell in copyCells)
{
@@ -212,7 +223,7 @@ private void UpdateStatusRows(StateSnapshot states)
private void UpdateLogRows(IEnumerable peerGroupStates)
{
- List failedChanged = new(0);
+ List failedChanged = [];
HashSet currentPeerGroups = new(this.failedPeerGroupToLogRowMap.Comparer);
foreach (PeerGroupState peerGroupState in peerGroupStates)
@@ -397,12 +408,12 @@ private W.NotifyIcon CreateNotifyIcon()
notifyIcon.Visible = true;
notifyIcon.MouseDoubleClick += this.NotifyIconMouseDoubleClick;
- notifyIconMenu.Items.AddRange(new W.ToolStripItem[]
- {
+ notifyIconMenu.Items.AddRange(
+ [
notifyIconViewMenu,
notifyIconSeparator,
notifyIconExitMenu,
- });
+ ]);
// notifyIconMenu.ShowImageMargin = false;
notifyIconViewMenu.Font = new Font(notifyIconMenu.Font, System.Drawing.FontStyle.Bold);
@@ -435,14 +446,25 @@ private void WindowSaverSaveSettings(object? sender, SettingsEventArgs e)
private void WindowClosing(object? sender, CancelEventArgs e)
{
- if (!this.IsSessionEnding && (this.appOptions?.ConfirmClose ?? false) && !e.Cancel)
+ if (!this.IsSessionEnding
+ && (this.appOptions?.ConfirmClose ?? false)
+ && !e.Cancel
+ && this.closingState == ClosingState.None)
{
- e.Cancel = !WindowsUtility.ShowQuestion(this, "Are you sure you want to exit?");
+ this.closingState = ClosingState.Requested;
+ try
+ {
+ e.Cancel = !WindowsUtility.ShowQuestion(this, "Are you sure you want to exit?");
+ }
+ finally
+ {
+ this.closingState = ClosingState.None;
+ }
}
if (!e.Cancel)
{
- this.closing = true;
+ this.closingState = ClosingState.Confirmed;
this.backgroundTimer?.Dispose();
this.CloseLogger();
}
@@ -450,7 +472,10 @@ private void WindowClosing(object? sender, CancelEventArgs e)
private void ExitExecuted(object? sender, ExecutedRoutedEventArgs e)
{
- this.Close();
+ if (this.closingState == ClosingState.None)
+ {
+ this.Close();
+ }
}
private void ViewOptionsExecuted(object? sender, ExecutedRoutedEventArgs e)
@@ -523,7 +548,9 @@ private void SimulateConnectionExecuted(object? sender, ExecutedRoutedEventArgs
private void BackgroundTimerCallback(object? state)
{
// Only let one Update run at a time. If the callback takes longer than 1 second, it will be invoked again from another thread.
- if (!this.closing && this.stateManager != null && Interlocked.CompareExchange(ref this.updatingLock, 1, 0) == 0)
+ if (this.closingState != ClosingState.Confirmed
+ && this.stateManager != null
+ && Interlocked.CompareExchange(ref this.updatingLock, 1, 0) == 0)
{
try
{
diff --git a/src/WirePeep/WirePeep.csproj b/src/WirePeep/WirePeep.csproj
index a5aa5ac..46dd2c0 100644
--- a/src/WirePeep/WirePeep.csproj
+++ b/src/WirePeep/WirePeep.csproj
@@ -9,7 +9,7 @@
-
+