From 29f7515f5340961ad6d70fa34299de1e938cb6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Tue, 16 Apr 2024 15:31:25 +0800 Subject: [PATCH] uy --- ProductionSystem/Untils/Tool/UxTool.cs | 26 +++++++++++++++----------- ProductionSystem/Untils/Tool/Uy.cs | 3 ++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ProductionSystem/Untils/Tool/UxTool.cs b/ProductionSystem/Untils/Tool/UxTool.cs index 44f229a..899183a 100644 --- a/ProductionSystem/Untils/Tool/UxTool.cs +++ b/ProductionSystem/Untils/Tool/UxTool.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.VisualBasic; +using NewLife.Threading; namespace ProductionSystem.Untils.Tool { @@ -112,27 +113,30 @@ namespace ProductionSystem.Untils.Tool return me.GetByteDat().ToHex(); } + private TimerX _timer; + public void Send() { - + var sendMes = GetMsg(mo); + _timer= new TimerX(DoBackup, sendMes, 100, 800) { Async = true }; + - Task.Run(() => - { - while (!Exit) - { - - mfSerialInfo.SendMessage(sendMes); - } - }); - - + } + + private void DoBackup(Object state) + { + XTrace.WriteLine("Ux定时器"); + mfSerialInfo.SendMessage(state.ToString()); } public bool Exit { get; set; } public void closeSend() { Exit = true; + _timer.Dispose(); + _timer = null; + Thread.Sleep(600); var sendMes = GetMsg(0); for (int i = 0; i < 100; i++) { diff --git a/ProductionSystem/Untils/Tool/Uy.cs b/ProductionSystem/Untils/Tool/Uy.cs index 8ec2f3c..a608a04 100644 --- a/ProductionSystem/Untils/Tool/Uy.cs +++ b/ProductionSystem/Untils/Tool/Uy.cs @@ -110,13 +110,14 @@ namespace ProductionSystem.Untils.Tool { var sendMes = GetMsg(mo); - _timer= new TimerX(DoBackup, sendMes, 100, 500) { Async = false }; + _timer= new TimerX(DoBackup, sendMes, 100, 800) { Async = true }; } private void DoBackup(Object state) { + XTrace.WriteLine("Uy定时器"); mfSerialInfo.SendMessage(state.ToString()); }