public bool Stop() { try { melsecMc.ConnectClose(); melsecMc.Dispose(); if (processor != null) { processor.Abort(); //解决线程过多情况,因为线程执行Abort,状态是AbortRequested,还是会存在继续执行 while (processor.ThreadState != ThreadState.Aborted) { Thread.Sleep(100); } } return(true); } catch (Exception ex) { DelegateState.InvokeDispatchStateEvent(ex.Message); return(false); } }