From 13ff7ab59f691feb24d9c988b7cdc75329af25f6 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 25 Jan 2023 08:49:48 +0100 Subject: [PATCH] Fix scritture concorrenti messaggi: - coda messaggi log (display) era List - trasformato come ConcurrentQueue --- IOB-WIN-NEXT/AdapterForm.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/IOB-WIN-NEXT/AdapterForm.cs b/IOB-WIN-NEXT/AdapterForm.cs index 06baa353..265003a0 100644 --- a/IOB-WIN-NEXT/AdapterForm.cs +++ b/IOB-WIN-NEXT/AdapterForm.cs @@ -3,6 +3,7 @@ using MapoSDK; using Newtonsoft.Json; using NLog; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; @@ -465,11 +466,13 @@ namespace IOB_WIN_NEXT try { // aggiungo in testa la NUOVA stringa (eventualmente multiline) - logWatchString.Insert(0, value); + logWatchString.Enqueue(value); // se supero limite --> trim! - if (logWatchString.Count > nLine2show) + string sTemp = ""; + while (logWatchString.Count > nLine2show) { - logWatchString = logWatchString.Take(nLine2show).ToList(); + logWatchString.TryDequeue(out sTemp); + //logWatchString = logWatchString.Take(nLine2show).ToList(); } DateTime adesso = DateTime.Now; if (logWatchWriteVeto < adesso) @@ -1031,7 +1034,7 @@ namespace IOB_WIN_NEXT /// /// Lista String da mostrare quale WatchLog corrente... /// - protected List logWatchString { get; set; } = new List(); + protected ConcurrentQueue logWatchString { get; set; } = new ConcurrentQueue(); /// /// Veto a NUOVE scritture in logWatch...