diff --git a/AutoShutdown/Plogon.cs b/AutoShutdown/Plogon.cs index 0effa1c..76162f9 100644 --- a/AutoShutdown/Plogon.cs +++ b/AutoShutdown/Plogon.cs @@ -1,17 +1,15 @@ using System; -using System.Diagnostics; using System.Reflection; using System.Windows.Forms; using AutoRetainerAPI; using Dalamud.Plugin; using Dalamud.Plugin.Services; using ECommons; -using FFXIVClientStructs.FFXIV.Client.System.Framework; using LLib; namespace AutoShutdown; -public class Plogon : IDalamudPlugin +public sealed class Plogon : IDalamudPlugin { private readonly AutoRetainerApi _autoRetainerApi; private readonly DalamudReflector _reflector; diff --git a/TheWatcher/Program.cs b/TheWatcher/Program.cs index 9439cf1..fbad8d5 100644 --- a/TheWatcher/Program.cs +++ b/TheWatcher/Program.cs @@ -2,16 +2,24 @@ namespace TheWatcher; -internal class Program +internal sealed class Program { public static async Task Main(string[] args) { Console.WriteLine("o.O"); - CancellationTokenSource cts = new CancellationTokenSource(); + using CancellationTokenSource cts = new CancellationTokenSource(); Console.CancelKeyPress += (_, e) => { - cts.Cancel(); + try + { + // ReSharper disable once AccessToDisposedClosure + cts.Cancel(); + } + catch (ObjectDisposedException) + { + } + e.Cancel = true; }; @@ -27,8 +35,8 @@ internal class Program else if (launchers.Length == 1) { Console.WriteLine($"Waiting for launcher {launchers.Single().Id} to finish"); - await launchers.Single().WaitForExitAsync(cts.Token); - await Task.Delay(1000, cts.Token); + await launchers.Single().WaitForExitAsync(cts.Token).ConfigureAwait(false); + await Task.Delay(1000, cts.Token).ConfigureAwait(false); continue; } @@ -42,7 +50,7 @@ internal class Program else if (ffxiv.Length == 1) { Console.WriteLine($"Waiting for FFXIV {ffxiv.Single().Id} to finish"); - await ffxiv.Single().WaitForExitAsync(cts.Token); + await ffxiv.Single().WaitForExitAsync(cts.Token).ConfigureAwait(false); } else { @@ -54,14 +62,14 @@ internal class Program }); if (process != null) { - await process.WaitForExitAsync(cts.Token); + await process.WaitForExitAsync(cts.Token).ConfigureAwait(false); Console.WriteLine("Started launcher..."); } else Console.WriteLine("No process started?"); } - await Task.Delay(1000, cts.Token); + await Task.Delay(1000, cts.Token).ConfigureAwait(false); } }