From b4245bf770bf6bd1ea6b9dafba7578b133e2af19 Mon Sep 17 00:00:00 2001
From: Niko Ehrenfeuchter <nikolaus.ehrenfeuchter@unibas.ch>
Date: Fri, 20 Jul 2018 14:16:41 +0200
Subject: [PATCH] Set "CanShutdown" property for the service

This way the service should now finally receive the system shutdown
events and be able to properly shut itself down.

Fixes #45
---
 ATxService/AutoTx.cs | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ATxService/AutoTx.cs b/ATxService/AutoTx.cs
index 27806a7..770e354 100644
--- a/ATxService/AutoTx.cs
+++ b/ATxService/AutoTx.cs
@@ -99,6 +99,9 @@ namespace ATxService
         /// AutoTx constructor
         /// </summary>
         public AutoTx() {
+            // make sure to receive system shutdown events to react properly:
+            CanShutdown = true;
+
             InitializeComponent();
             SetupFileLogging();
             Log.Info("=".PadLeft(80, '='));
@@ -440,6 +443,8 @@ namespace ATxService
             Log.Info("RoboSharp version: [{0}]", roboAssembly.GetName().Version);
             Log.Info("Robosharp product version: [{0}]", roboVersionInfo.ProductVersion);
             Log.Info("=".PadLeft(80, '='));
+            Log.Trace($"ServiceBase.CanShutdown property: {CanShutdown}");
+            Log.Trace("=".PadLeft(80, '='));
         }
 
         /// <summary>
-- 
GitLab