From 10840007e9d96483e747800969ebba38fa5eab6a Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 28 Aug 2022 00:34:07 -0500 Subject: add Clock --- src/slskd/Core/Clock.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/slskd/Core/Clock.cs (limited to 'src/slskd/Core/Clock.cs') diff --git a/src/slskd/Core/Clock.cs b/src/slskd/Core/Clock.cs new file mode 100644 index 00000000..4d2e6c10 --- /dev/null +++ b/src/slskd/Core/Clock.cs @@ -0,0 +1,40 @@ +// +// Copyright (c) slskd Team. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see https://www.gnu.org/licenses/. +// + +namespace slskd +{ + using System; + using System.Timers; + + /// + /// The application clock, used for time based events. + /// + public static class Clock + { + static Clock() + { + EveryMinuteTimer.Elapsed += (_, _) => EveryMinute?.Invoke(null, EventArgs.Empty); + } + + /// + /// Fires every 60 seconds. + /// + public static event EventHandler EveryMinute; + + private static Timer EveryMinuteTimer { get; } = new Timer() { AutoReset = true, Interval = 60000, Enabled = true }; + } +} \ No newline at end of file -- cgit v1.2.3