dep_yangw
我叫锄头 10 months ago
parent 7962380612
commit 29f7515f53

@ -9,6 +9,7 @@ using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
using NewLife.Threading;
namespace ProductionSystem.Untils.Tool namespace ProductionSystem.Untils.Tool
{ {
@ -112,27 +113,30 @@ namespace ProductionSystem.Untils.Tool
return me.GetByteDat().ToHex(); return me.GetByteDat().ToHex();
} }
private TimerX _timer;
public void Send() public void Send()
{ {
var sendMes = GetMsg(mo); 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 bool Exit { get; set; }
public void closeSend() public void closeSend()
{ {
Exit = true; Exit = true;
_timer.Dispose();
_timer = null;
Thread.Sleep(600);
var sendMes = GetMsg(0); var sendMes = GetMsg(0);
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {

@ -110,13 +110,14 @@ namespace ProductionSystem.Untils.Tool
{ {
var sendMes = GetMsg(mo); 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) private void DoBackup(Object state)
{ {
XTrace.WriteLine("Uy定时器");
mfSerialInfo.SendMessage(state.ToString()); mfSerialInfo.SendMessage(state.ToString());
} }

Loading…
Cancel
Save