qqq
C3031
2025-12-31 cbfa25a6e8df52ff785be28f29d0b1ae1f39cbb3
LB_SmartVision/Forms/Pages/ProcessPage/ProcessControl.cs
@@ -43,6 +43,11 @@
            if (ProcessRunBll != null)
                this.label1.Text = $"总数:{ProcessRunBll.total}";
            this.isClosed = false ;
            var TaskPhotoContinue = Task.Factory.StartNew(() =>
            {
                ThreadCircleRun();
            });
        }
        public void SetTitle(string title)
@@ -149,37 +154,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();
@@ -192,9 +196,7 @@
                        ShowHoImage(RecordImage);
                }
                catch { }
                //}));
                Thread.Sleep(100);
                Thread.Sleep(33);
            }
        }