dep_yangw
我叫锄头 10 months ago
parent c61055ba0d
commit 7962380612

@ -4,6 +4,7 @@ using System.Threading.Tasks;
using NewLife;
using NewLife.Log;
using NewLife.Serialization;
using NewLife.Threading;
namespace ProductionSystem.Untils.Tool
{
@ -103,22 +104,23 @@ namespace ProductionSystem.Untils.Tool
public bool Exit { get; set; }
private TimerX _timer;
public void Send()
{
var sendMes = GetMsg(mo);
_timer= new TimerX(DoBackup, sendMes, 100, 500) { Async = false };
Task.Run(() =>
{
while (!Exit)
{
mfSerialInfo.SendMessage(sendMes);
}
});
}
private void DoBackup(Object state)
{
mfSerialInfo.SendMessage(state.ToString());
}
public string GetMsg(int num)
{
uint seep = uint.Parse((num * 0.4).ToString());
@ -136,6 +138,9 @@ namespace ProductionSystem.Untils.Tool
public void closeSend()
{
Exit = true;
_timer.Dispose();
_timer = null;
Thread.Sleep(600);
var sendMes = GetMsg(0);
for (int i = 0; i < 100; i++)
{

Loading…
Cancel
Save