2 Commits
Author SHA1 Message Date
BlubbFish 3e79b425a5 Change netcore 2019-12-01 17:53:11 +01:00
BlubbFish 9326ab8659 Change signalhandling netcore 2019-11-29 14:44:45 +01:00
5 changed files with 17 additions and 10 deletions
+12 -5
View File
@@ -4,21 +4,25 @@ 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
#if NETCOREAPP
private void Default_Unloading(AssemblyLoadContext obj) {
Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.SetupShutdown: Signalhandler Windows INT recieved.");
Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.SetupShutdown: Signalhandler Windows NETCORE recieved.");
this.RunningProcess = false;
Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.WaitForShutdown: Shutdown.");
this.Dispose();
}
#endif
@@ -43,22 +47,25 @@ namespace BlubbFish.Utils.IoT.Bots {
} else {
#if NETCOREAPP
AssemblyLoadContext.Default.Unloading += this.Default_Unloading;
#else
Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.WaitForShutdown: Signalhandler Netcore attached.");
#endif
Console.CancelKeyPress += new ConsoleCancelEventHandler(this.SetupShutdown);
Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.WaitForShutdown: Signalhandler Windows attached.");
#endif
}
while(this.RunningProcess) {
Thread.Sleep(100);
}
Console.WriteLine("BlubbFish.Utils.IoT.Bots.Bot.WaitForShutdown: Shutdown.");
}
public virtual void Dispose() {
#if !NETCOREAPP
if(this.sig_thread != null && this.sig_thread.IsAlive) {
this.sig_thread.Abort();
}
#endif
}
}
}
+1
View File
@@ -65,6 +65,7 @@
<Compile Include="Webserver.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\CHANGELOG.md" />
<Content Include="..\CONTRIBUTING.md" />
<Content Include="..\LICENSE" />
<Content Include="..\README.md" />
+1
View File
@@ -38,6 +38,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="../CHANGELOG.md" />
<Content Include="../CONTRIBUTING.md" />
<Content Include="../LICENSE" />
<Content Include="../README.md" />
+2 -4
View File
@@ -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
View File