From f1c8372f8be80156d258af0e6a6a3c5a40915654 Mon Sep 17 00:00:00 2001 From: Zontreck Date: Sat, 20 Jun 2020 20:44:46 -0700 Subject: [PATCH] Update bot to remove lockfile on exit --- Program.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Program.cs b/Program.cs index 514b143..304171d 100644 --- a/Program.cs +++ b/Program.cs @@ -61,7 +61,7 @@ namespace Bot MainConfiguration.Instance.Load(); MainConfiguration conf = MainConfiguration.Instance; //MasterObjectCaches = ObjectCaches.Instance; - + AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; if (args.Length == 2) { @@ -594,6 +594,12 @@ namespace Bot //System.Console.ReadKey(); } + private static void CurrentDomain_ProcessExit(object sender, EventArgs e) + { + // Exit the process + if (File.Exists("Bot.lockfile")) File.Delete("Bot.lockfile"); + } + private static void onJoinGroupChat(object sender, GroupChatJoinedEventArgs e) { if (e.Success)