From a63e5ce3c286cf4fc652d476bfe91f5968d30132 Mon Sep 17 00:00:00 2001 From: DESKTOP-G1UHLH2 Date: Wed, 9 Oct 2024 15:45:36 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BF=AE=E6=94=B9=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E6=95=B0=E6=8D=AE=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SlnMesnac.TouchSocket/ApiServer.cs | 9 ++++++++- SlnMesnac.WPF/ViewModel/IndexViewModel.cs | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SlnMesnac.TouchSocket/ApiServer.cs b/SlnMesnac.TouchSocket/ApiServer.cs index 6349065..d37b0cd 100644 --- a/SlnMesnac.TouchSocket/ApiServer.cs +++ b/SlnMesnac.TouchSocket/ApiServer.cs @@ -4,6 +4,7 @@ using System.IO; using System.Linq; using System.Numerics; using System.Text; +using System.Threading.Tasks; using System.Web; using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.Logging; @@ -190,7 +191,13 @@ namespace SlnMesnac.TouchSocket log.ErrMsg=e.Message; } - _baseLogService.Insert(log); + Task.Run(() => + { + lock (string.Empty) + { + _baseLogService.Insert(log); + } + }); return new Back(); diff --git a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs index 9b52c19..890bef2 100644 --- a/SlnMesnac.WPF/ViewModel/IndexViewModel.cs +++ b/SlnMesnac.WPF/ViewModel/IndexViewModel.cs @@ -143,6 +143,7 @@ namespace SlnMesnac.WPF.ViewModel /// /// 扫描记录 /// + private List scanLogModelsItems = new List(); private ObservableCollection _scanItems = new ObservableCollection(); public ObservableCollection ScanItems { @@ -162,7 +163,9 @@ namespace SlnMesnac.WPF.ViewModel TagCode = info.Rfid; ImagePath = info.Url; - ScanItems.Add(info); + scanLogModelsItems.Add(info); + + ScanItems = new ObservableCollection(scanLogModelsItems.OrderByDescending(x=>x.CreateTime).ToList()); TagAmount++;