diff --git a/Bot-Utils/ABot.cs b/Bot-Utils/ABot.cs index 76ba4b9..0a47e55 100644 --- a/Bot-Utils/ABot.cs +++ b/Bot-Utils/ABot.cs @@ -4,27 +4,26 @@ using System.Threading; namespace BlubbFish.Utils.IoT.Bots { public abstract class ABot { + #if !NETCOREAPP private Thread sig_thread; + #endif private Boolean RunningProcess = true; protected ProgramLogger logger = new ProgramLogger(); - #if !NETCOREAPP private void SetupShutdown(Object sender, ConsoleCancelEventArgs e) { e.Cancel = true; Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.SetupShutdown: Signalhandler Windows INT recieved."); this.RunningProcess = false; } - #else private void Default_Unloading(AssemblyLoadContext obj) { Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.SetupShutdown: Signalhandler Windows INT recieved."); this.RunningProcess = false; } - #endif protected void WaitForShutdown() { if(Type.GetType("Mono.Runtime") != null) { - #if !NETCOREAPP + #if !NETCOREAPP this.sig_thread = new Thread(delegate () { Mono.Unix.UnixSignal[] signals = new Mono.Unix.UnixSignal[] { new Mono.Unix.UnixSignal(Mono.Unix.Native.Signum.SIGTERM), @@ -40,13 +39,11 @@ namespace BlubbFish.Utils.IoT.Bots { }); this.sig_thread.Start(); #endif - } else { - #if NETCOREAPP + } else { AssemblyLoadContext.Default.Unloading += this.Default_Unloading; - #else + Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.WaitForShutdown: Signalhandler Netcore attached."); Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown); Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.WaitForShutdown: Signalhandler Windows attached."); - #endif } while(this.RunningProcess) { Thread.Sleep(100); @@ -56,9 +53,11 @@ namespace BlubbFish.Utils.IoT.Bots { public virtual void Dispose() { + #if !NETCOREAPP if(this.sig_thread != null && this.sig_thread.IsAlive) { this.sig_thread.Abort(); } + #endif } } } diff --git a/Bot-Utils/Properties/AssemblyInfo.cs b/Bot-Utils/Properties/AssemblyInfo.cs index 3126b45..7866e9b 100644 --- a/Bot-Utils/Properties/AssemblyInfo.cs +++ b/Bot-Utils/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ -#if NETCOREAPP -#else +#if !NETCOREAPP using System.Reflection; using System.Resources; using System.Runtime.InteropServices; @@ -37,7 +36,7 @@ using System.Runtime.InteropServices; // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.2.1")] [assembly: AssemblyFileVersion("1.2.1")] - +#endif /* * 1.1.0 Remove Helper from Bot-Utils * 1.1.1 Update to local librarys @@ -53,4 +52,3 @@ using System.Runtime.InteropServices; * 1.2.0 Refactor Bot to ABot and refere MultiSourceBot, Webserver and Bot to it. Add MultiSourceBot. Rewrite Mqtt module so that it not need to watch the connection. * 1.2.1 When using Dispose, kill also mqtt connection and other tiny fixes */ -#endif \ No newline at end of file