From 7d2530a3ed498b129c3949b4c7d33f913ad34a94 Mon Sep 17 00:00:00 2001 From: emkael Date: Wed, 28 Aug 2019 19:09:56 +0200 Subject: Flushing file-based log on form exit --- spedytor/Form1.Designer.cs | 1 + spedytor/Form1.cs | 5 +++++ spedytor/Logger.cs | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/spedytor/Form1.Designer.cs b/spedytor/Form1.Designer.cs index f411cae..a0f77e3 100644 --- a/spedytor/Form1.Designer.cs +++ b/spedytor/Form1.Designer.cs @@ -204,6 +204,7 @@ this.MinimizeBox = false; this.Name = "Form1"; this.Text = "Spedytor"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.Form1_FormClosed); this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.nInterval)).EndInit(); this.ResumeLayout(false); diff --git a/spedytor/Form1.cs b/spedytor/Form1.cs index f3f47c6..928682a 100644 --- a/spedytor/Form1.cs +++ b/spedytor/Form1.cs @@ -181,5 +181,10 @@ namespace spedytor { Logger.getLogger(this.tbLog, LOG_FILENAME).tick(); } + + private void Form1_FormClosed(object sender, FormClosedEventArgs e) + { + Logger.getLogger(this.tbLog, LOG_FILENAME).cleanup(); + } } } diff --git a/spedytor/Logger.cs b/spedytor/Logger.cs index c32d91a..7b88177 100644 --- a/spedytor/Logger.cs +++ b/spedytor/Logger.cs @@ -80,5 +80,13 @@ namespace spedytor } } } + + public void cleanup() + { + if (this.file != null) + { + this.file.Close(); + } + } } } -- cgit v1.2.3