Move OnTimeChanged event from ASF to OS

This commit is contained in:
JustArchi
2017-02-13 21:16:12 +01:00
parent 56983c0470
commit cbcc045369
2 changed files with 5 additions and 5 deletions

View File

@@ -32,7 +32,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using ArchiSteamFarm.JSON; using ArchiSteamFarm.JSON;
using ArchiSteamFarm.Localization; using ArchiSteamFarm.Localization;
using Microsoft.Win32;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
internal static class ASF { internal static class ASF {
@@ -243,8 +242,6 @@ namespace ArchiSteamFarm {
FileSystemWatcher.Renamed += OnRenamed; FileSystemWatcher.Renamed += OnRenamed;
FileSystemWatcher.EnableRaisingEvents = true; FileSystemWatcher.EnableRaisingEvents = true;
SystemEvents.TimeChanged += OnTimeChanged;
} }
private static async Task CreateBot(string botName) { private static async Task CreateBot(string botName) {
@@ -386,8 +383,6 @@ namespace ArchiSteamFarm {
CreateBot(newBotName).Forget(); CreateBot(newBotName).Forget();
} }
private static async void OnTimeChanged(object sender, EventArgs e) => await MobileAuthenticator.OnTimeChanged().ConfigureAwait(false);
private static async Task RestartOrExit() { private static async Task RestartOrExit() {
if (Program.GlobalConfig.AutoRestart) { if (Program.GlobalConfig.AutoRestart) {
ArchiLogger.LogGenericInfo(Strings.Restarting); ArchiLogger.LogGenericInfo(Strings.Restarting);

View File

@@ -25,6 +25,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ArchiSteamFarm.Localization; using ArchiSteamFarm.Localization;
using Microsoft.Win32;
namespace ArchiSteamFarm { namespace ArchiSteamFarm {
internal static class OS { internal static class OS {
@@ -39,6 +40,8 @@ namespace ArchiSteamFarm {
KeepWindowsSystemActive(); KeepWindowsSystemActive();
break; break;
} }
SystemEvents.TimeChanged += OnTimeChanged;
} }
private static void KeepWindowsSystemActive() { private static void KeepWindowsSystemActive() {
@@ -53,6 +56,8 @@ namespace ArchiSteamFarm {
} }
} }
private static async void OnTimeChanged(object sender, EventArgs e) => await MobileAuthenticator.OnTimeChanged().ConfigureAwait(false);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern EExecutionState SetThreadExecutionState(EExecutionState executionState); private static extern EExecutionState SetThreadExecutionState(EExecutionState executionState);