From f56a4e51cf2b42c979af3037d20ffff6dc48b0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9rald=20Barr=C3=A9?= Date: Sat, 28 Dec 2024 19:56:53 -0500 Subject: [PATCH] Auto close the app after a period of inactivity --- .../Program.cs | 10 ++++++++++ .../Meziantou.Framework.InlineSnapshotTesting.csproj | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Meziantou.Framework.InlineSnapshotTesting.Prompt.NotificationTray/Program.cs b/src/Meziantou.Framework.InlineSnapshotTesting.Prompt.NotificationTray/Program.cs index c9177afd4..8d1c0ccc9 100644 --- a/src/Meziantou.Framework.InlineSnapshotTesting.Prompt.NotificationTray/Program.cs +++ b/src/Meziantou.Framework.InlineSnapshotTesting.Prompt.NotificationTray/Program.cs @@ -4,13 +4,23 @@ namespace Meziantou.Framework.InlineSnapshotTesting.Prompt.NotificationTray; internal static class Program { + private static readonly System.Threading.Timer Timer = new(_ => Application.Exit()); + + private static void ResetTimer() + { + Timer.Change(TimeSpan.FromHours(4), Timeout.InfiniteTimeSpan); + } + [STAThread] public static void Main() { const string AppId = "Local\\6495bb03-4c5c-4695-bb73-310b06982b5c"; using var mutex = new Mutex(initiallyOwned: false, AppId); if (!mutex.WaitOne(0)) + { + ResetTimer(); return; + } Application.EnableVisualStyles(); using var appContext = new MyCustomApplicationContext(); diff --git a/src/Meziantou.Framework.InlineSnapshotTesting/Meziantou.Framework.InlineSnapshotTesting.csproj b/src/Meziantou.Framework.InlineSnapshotTesting/Meziantou.Framework.InlineSnapshotTesting.csproj index e8bf3457a..3a2a07ef6 100644 --- a/src/Meziantou.Framework.InlineSnapshotTesting/Meziantou.Framework.InlineSnapshotTesting.csproj +++ b/src/Meziantou.Framework.InlineSnapshotTesting/Meziantou.Framework.InlineSnapshotTesting.csproj @@ -5,7 +5,7 @@ Enables verification of objects using inline snapshots $(DefineConstants);DEBUG_TaskDialogPrompt - 3.3.5 + 3.3.6 $(NoWarn);NU5100