From 065674f3eea53cd84244dbb7ba1a994f86dde1ab Mon Sep 17 00:00:00 2001
From: C3031 <shitiangui@lanpucloud.cn>
Date: 星期五, 30 一月 2026 09:09:47 +0800
Subject: [PATCH] 

---
 LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.cs |   84 +++++++++++++++++++++++------------------
 1 files changed, 47 insertions(+), 37 deletions(-)

diff --git a/LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.cs b/LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.cs
index ee4545a..41f0e6b 100644
--- a/LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.cs
+++ b/LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.cs
@@ -10,6 +10,25 @@
     {
         UserHSmartWindowControl UserHSmartWindowControl = new UserHSmartWindowControl();
 
+        public string Title = string.Empty;
+
+        public event Control_MouseDown event_MouseDown;
+        public event Control_MouseDoubleClick event_MouseDoubleClick;
+        private void event_mouseDown(object sender, MouseEventArgs e)
+        {
+            if (event_MouseDown != null)
+            {
+                event_MouseDown(sender, e);
+            }
+        }
+        private void event_mouseDoubleClick(object sender, MouseEventArgs e)
+        {
+            if (event_MouseDoubleClick != null)
+            {
+                event_MouseDoubleClick(this, e);
+            }
+        }
+
         ProcessRunBll ProcessRunBll
         {
             get
@@ -38,11 +57,17 @@
         {
             this.panel1.Controls.Add(this.UserHSmartWindowControl);
             this.UserHSmartWindowControl.Dock = DockStyle.Fill;
-
+            this.UserHSmartWindowControl.event_MouseDoubleClick += event_mouseDoubleClick;
+            this.UserHSmartWindowControl.event_MouseDown += event_mouseDown;
             SetTitle(_Layout.ProcessName);
-
+            Title = _Layout.Title;
             if (ProcessRunBll != null)
                 this.label1.Text = $"鎬绘暟锛歿ProcessRunBll.total}";
+            this.isClosed = false;
+            var TaskPhotoContinue = Task.Factory.StartNew(() =>
+            {
+                ThreadCircleRun();
+            });
         }
 
         public void SetTitle(string title)
@@ -72,19 +97,17 @@
                 }));
             }
             else
-            {
                 UserHSmartWindowControl.ClearObj();
-            }
         }
 
         /// <summary>
         /// 寮傛鏄剧ず鍥剧墖
         /// </summary>
         /// <param name="ho_image"></param>
-        public void ShowHoImage(HImage ho_image)
+        public void ShowHoImage(HObject ho_image)
         {
-            string str = this.lblTitle.Text;
             UserHSmartWindowControl.hImage = ho_image;
+
             if (this.InvokeRequired)
             {
                 this.BeginInvoke(new Action(() =>
@@ -93,9 +116,7 @@
                 }));
             }
             else
-            {
                 this.label1.Text = $"鎬绘暟锛歿ProcessRunBll.total}";
-            }
         }
 
         public bool Run(out string msg)
@@ -107,9 +128,7 @@
             }
 
             if (isCircleRuning || ProcessRunBll.bRuning)
-            {
                 ProcessRunBll.LogInfo($"{ProcessRunBll.Name}姝e湪杩愯", LogInfoType.ERROR);
-            }
 
             ProcessRunBll.Run();
 
@@ -126,19 +145,15 @@
                 try
                 {
                     if (ProcessRunBll == null)
-                    {
                         return;
-                    }
 
                     ProcessRunBll.LogInfo(string.Format("娴佺▼[{0}]寮�濮嬭繍琛�", this.ProcessRunBll.Name), LogInfoType.INFO);
 
                     ClearObj();
                     result = Run(out msg);
 
-                    if (ProcessRunBll.GetImage(_Layout, out _, out HImage RecordImage))
-                    {
+                    if (ProcessRunBll.GetImage(_Layout, out _, out HObject RecordImage))
                         ShowHoImage(RecordImage);
-                    }
                 }
                 catch { msg = "杩愯鍑虹幇浜嗗紓甯�"; }
 
@@ -159,37 +174,36 @@
 
                 if (isCircleRuning)
                 {
-                    threadCircleRun = new Thread(ThreadCircleRun);
-                    threadCircleRun.IsBackground = true;
-                    threadCircleRun.Start();
+                    this.mAutoResetEvent.Set();
                 }
                 else
                 {
                     isCircleRuning = false;
-                    //threadCircleRun.Abort();
                 }
+                if (!isCircleRuning)
+                {
+                    ProcessRunBll.LogInfo($"{ProcessRunBll.Name}鍏抽棴杩炵画杩愯", LogInfoType.PASS);
+                    return;
+                }
+
+                ProcessRunBll.LogInfo($"{ProcessRunBll.Name}寮�鍚繛缁繍琛�", LogInfoType.WARN);
             }
             catch { }
         }
-
-        Thread threadCircleRun = null;
+        private AutoResetEvent mAutoResetEvent = new AutoResetEvent(false);
+        bool isClosed = false;
 
         void ThreadCircleRun()
         {
-            if (!isCircleRuning)
+            while (!isClosed)
             {
-                ProcessRunBll.LogInfo($"{ProcessRunBll.Name}鍏抽棴杩炵画杩愯", LogInfoType.PASS);
-                return;
-            }
-
-            ProcessRunBll.LogInfo($"{ProcessRunBll.Name}寮�鍚繛缁繍琛�", LogInfoType.WARN);
-
-            while (isCircleRuning)
-            {
-                //this.BeginInvoke(new Action(() =>
-                //{
                 try
                 {
+                    if (isCircleRuning == false)
+                    {
+                        this.mAutoResetEvent.WaitOne();
+                    }
+
                     ProcessRunBll.LogInfo($"{ProcessRunBll.Name}寮�濮嬭繍琛�", LogInfoType.WARN);
                     ClearObj();
                     bool result = ProcessRunBll.Run();
@@ -198,14 +212,10 @@
                     ProcessRunBll.LogInfo($"{ProcessRunBll.Name}杩愯缁撴潫,缁撴灉涓�:{msg}"
                         , result ? LogInfoType.PASS : LogInfoType.ERROR);
 
-                    if (ProcessRunBll.GetImage(_Layout, out _, out HImage RecordImage))
-                    {
+                    if (ProcessRunBll.GetImage(_Layout, out _, out HObject RecordImage))
                         ShowHoImage(RecordImage);
-                    }
                 }
                 catch { }
-                //}));
-
                 Thread.Sleep(33);
             }
         }

--
Gitblit v1.9.3