From adf724bd7bbbfb8123de3cd446c3715a6924efff Mon Sep 17 00:00:00 2001 From: Serraniel Date: Mon, 17 Apr 2017 11:20:57 +0200 Subject: [PATCH] Probably fixed an issue with the ArchivableConsoleLogMemory on disposing --- .../Properties/AssemblyInfo.cs | 4 ++-- SweetLib/Properties/AssemblyInfo.cs | 4 ++-- .../Memory/ArchivableConsoleLogMemory.cs | 19 ++++++++++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/SweetLib.Demo.Console/Properties/AssemblyInfo.cs b/SweetLib.Demo.Console/Properties/AssemblyInfo.cs index 295fad9..1e48fc1 100644 --- a/SweetLib.Demo.Console/Properties/AssemblyInfo.cs +++ b/SweetLib.Demo.Console/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.22.0")] -[assembly: AssemblyFileVersion("1.0.22.0")] +[assembly: AssemblyVersion("1.0.23.0")] +[assembly: AssemblyFileVersion("1.0.23.0")] diff --git a/SweetLib/Properties/AssemblyInfo.cs b/SweetLib/Properties/AssemblyInfo.cs index 014b9d3..cc97aa7 100644 --- a/SweetLib/Properties/AssemblyInfo.cs +++ b/SweetLib/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.24.0")] -[assembly: AssemblyFileVersion("0.1.24.0")] +[assembly: AssemblyVersion("0.1.25.0")] +[assembly: AssemblyFileVersion("0.1.25.0")] diff --git a/SweetLib/Utils/Logger/Memory/ArchivableConsoleLogMemory.cs b/SweetLib/Utils/Logger/Memory/ArchivableConsoleLogMemory.cs index 108a898..482dac5 100644 --- a/SweetLib/Utils/Logger/Memory/ArchivableConsoleLogMemory.cs +++ b/SweetLib/Utils/Logger/Memory/ArchivableConsoleLogMemory.cs @@ -34,12 +34,25 @@ namespace SweetLib.Utils.Logger.Memory Dispose(false); } - private void ProcessQueue() + private void ProcessQueue(bool isDisposing = false) { if (LogQueue.IsEmpty) return; - lock (this) + // if we are disposing no need to lock. This might cause issues! + if (!isDisposing) + { + lock (this) + { + if (LogQueue.IsEmpty) + return; + + LogMessage message; + if (LogQueue.TryDequeue(out message)) + File.AppendAllText(TempFile, message.ToString()); + } + } + else { if (LogQueue.IsEmpty) return; @@ -129,7 +142,7 @@ namespace SweetLib.Utils.Logger.Memory { QueueTimer.Dispose(); - ProcessQueue(); + ProcessQueue(true); if (AutoArchiveOnDispose) {