From 6c985ca1423b805e83824d98353ab5132f047902 Mon Sep 17 00:00:00 2001 From: xcd <834800634@qq.com> Date: 星期一, 13 七月 2020 12:32:53 +0800 Subject: [PATCH] 更改流程载入操作 --- src/Bro.UI.Config/MenuForms/FrmOperation.cs | 45 +++++++++++++++++++++++++++++---------------- 1 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/Bro.UI.Config/MenuForms/FrmOperation.cs b/src/Bro.UI.Config/MenuForms/FrmOperation.cs index 891d678..455f1aa 100644 --- a/src/Bro.UI.Config/MenuForms/FrmOperation.cs +++ b/src/Bro.UI.Config/MenuForms/FrmOperation.cs @@ -28,16 +28,21 @@ LoadProcessCode(); LoadProductionCode(); - Task.Run(() => - { - Thread.Sleep(1000); + //Task.Run(() => + //{ + // Thread.Sleep(1000); - if ((!plProcess.Visible) && (!plProduct.Visible) && _isFirstLoad) - { - LoadProcess(); - _isFirstLoad = false; - } - }); + // if ((!plProcess.Visible) && (!plProduct.Visible) && _isFirstLoad) + // { + // LoadProcess(); + // _isFirstLoad = false; + // } + //}); + //if ((!plProcess.Visible) && (!plProduct.Visible) && _isFirstLoad) + //{ + // LoadProcess(); + // _isFirstLoad = false; + //} } #region Load Codes @@ -128,6 +133,12 @@ private void FrmOperation_Load(object sender, System.EventArgs e) { + //if ((!plProcess.Visible) && (!plProduct.Visible) && _isFirstLoad) + //{ + // LoadProcess(); + // _isFirstLoad = false; + //} + btnStart.Enabled = true; } @@ -140,7 +151,7 @@ } bool isStart = true; - private void btnStart_Click(object sender, System.EventArgs e) + private async void btnStart_Click(object sender, System.EventArgs e) { if (Process == null) { @@ -157,11 +168,11 @@ //if (Process.ProcessState != EnumHelper.DeviceState.DSOpen) if (isStart) { - ProcessOperation(true); + await ProcessOperation(true); } else { - ProcessOperation(false); + await ProcessOperation(false); } isStart = !isStart; @@ -172,7 +183,8 @@ } finally { - this.BeginInvoke(new Action(() => btnStart.Enabled = true)); + //this.BeginInvoke(new Action(() => btnStart.Enabled = true)); + btnStart.Enabled = true; } //}); } @@ -193,6 +205,7 @@ } //Process.OnProcessStateChanged += Process_OnProcessStateChanged; + Process.OnLog -= Process_OnLog; Process.OnLog += Process_OnLog; _currentProcssCode = _processCode; @@ -255,11 +268,11 @@ // } //} - private void ProcessOperation(bool isStart) + private async Task ProcessOperation(bool isStart) { if (isStart) { - Process.Open(); + await Task.Run(() => Process.Open()); //this.BeginInvoke(new Action(() => //{ @@ -273,7 +286,7 @@ } else { - Process.Close(); + await Task.Run(() => Process.Close()); //this.BeginInvoke(new Action(() => //{ -- Gitblit v1.8.0