diff options
| author | JP Dillingham <jp@dillingham.me> | 2023-10-01 17:00:01 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2023-10-01 17:00:01 -0500 |
| commit | 26e48163ca53b61a82c4a5fd5a40228096aae12c (patch) | |
| tree | f20b89f1a4a620f67be0c1fb33eca1f7b55febc4 /src | |
| parent | 6886d768afdf2ed36b571e7810132a1df6ebb01b (diff) | |
| download | slskd-26e48163ca53b61a82c4a5fd5a40228096aae12c.tar.gz | |
stop the clock on shutdown
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Application.cs | 3 | ||||
| -rw-r--r-- | src/slskd/Core/Clock.cs | 11 |
2 files changed, 14 insertions, 0 deletions
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))); } + /// <summary> + /// Stops the clock. + /// </summary> + 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); |
