From 26e48163ca53b61a82c4a5fd5a40228096aae12c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 1 Oct 2023 17:00:01 -0500 Subject: stop the clock on shutdown --- src/slskd/Application.cs | 3 +++ src/slskd/Core/Clock.cs | 11 +++++++++++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs index dabf112e..0ebffe94 100644 --- a/src/slskd/Application.cs +++ b/src/slskd/Application.cs @@ -446,6 +446,9 @@ namespace slskd { ShuttingDown = true; Log.Warning("Application is shutting down"); + + Clock.Stop(); + Client.Disconnect("Shutting down", new ApplicationShutdownException("Shutting down")); Client.Dispose(); Log.Information("Client stopped"); diff --git a/src/slskd/Core/Clock.cs b/src/slskd/Core/Clock.cs index 4ee29ee3..31519fc8 100644 --- a/src/slskd/Core/Clock.cs +++ b/src/slskd/Core/Clock.cs @@ -72,6 +72,17 @@ namespace slskd Task.Run(() => Fire(EveryHour))); } + /// + /// Stops the clock. + /// + public static void Stop() + { + EveryMinuteTimer.Stop(); + EveryFiveMinutesTimer.Stop(); + EveryThirtyMinutesTimer.Stop(); + EveryHourTimer.Stop(); + } + private static Timer EveryMinuteTimer { get; } = CreateTimer(interval: 1000 * 60); private static Timer EveryFiveMinutesTimer { get; } = CreateTimer(interval: 1000 * 60 * 5); private static Timer EveryThirtyMinutesTimer { get; } = CreateTimer(interval: 1000 * 60 * 30); -- cgit v1.2.3