Browse Source

消除所有抄写窗口在抄写时,仍能响应回车键的问题。同时'刷新'按钮在抄写线程运行时,禁用Abort。

jianfeng1.wang 2 years ago
parent
commit
5a5c622f10
1 changed files with 20 additions and 2 deletions
  1. 20 2
      FactoryTool_CShare/Views/OperationPanel.cs

+ 20 - 2
FactoryTool_CShare/Views/OperationPanel.cs

@@ -5314,6 +5314,12 @@ namespace MOKA_Factory_Tools
         /// <param name="e"></param>
         private void OnBtnWBView(object sender, EventArgs e)
         {
+            if (IsThreadRunning)
+            {
+                Log.WriteInfoLog("Thread is running for key!");
+                return;
+            }
+
             SNText.Focus();
             if (FunctionSettingNow.WriteWB)
             {
@@ -5578,6 +5584,12 @@ namespace MOKA_Factory_Tools
         /// <param name="e"></param>
         private void OnBtnOtherView(object sender, EventArgs e)
         {
+            if (IsThreadRunning)
+            {
+                Log.WriteInfoLog("Thread is running for key!");
+                return;
+            }
+
             if (midListNow.rokuCustomer != null)
                 MessageBox.Show("Roku TV\r\n" + "Brand:" +
                     midListNow.rokuCustomer.brand + "\r\nOEM Model:" +
@@ -5586,7 +5598,7 @@ namespace MOKA_Factory_Tools
                     JsonConvert.SerializeObject(midListNow.rokuCustomer.data).ToString() + "\r\nData:" +
                     midListNow.rokuCustomer.remotetype, LResource.ProductMsg);
             else
-                MessageBox.Show("null");
+                MessageBox.Show("ruku info is nothing!");
         }
 
         /// <summary>
@@ -5727,6 +5739,11 @@ namespace MOKA_Factory_Tools
         /// </summary>
         private void OnBtnRefresh(object sender, EventArgs e)
         {
+            if (IsThreadRunning)
+            {
+                return;
+            }
+
             usingTime = 0;
             EnableText(SNText);
             EnableButton(BtnClickstart);
@@ -5736,7 +5753,7 @@ namespace MOKA_Factory_Tools
             {
                 if (WritekeyThread.IsAlive)
                 {
-                    WritekeyThread.Abort();
+                    WritekeyThread.Abort(); // Abort出现无法中断线程的问题,会导致界面卡死, 所以如果IsThreadRunning=true,直接退出;
                     if (timer1.Enabled)
                     {
                         timer1.Stop();
@@ -5748,6 +5765,7 @@ namespace MOKA_Factory_Tools
                 }
             }
             SN = "";  // 需要在线程结束后才能清空;
+            IsThreadRunning = false;
             UsingTime_Text.Text = "0";
             GC.Collect();
             MessageBox.Show(LResource.RefreshPanel);