zoukankan      html  css  js  c++  java
  • C# 线程 正确使用Thread.Join()停止方式

    /// <summary>
            /// 停下线程
            /// </summary>
            private void MyStopTask()
            {
                new Action(() => {
                    if (thread != null)
                    {
                        while (thread.ThreadState != System.Threading.ThreadState.Stopped)//必须等线程完全停止了,否则会出现冲突。  
                        {
                            try
                            {
                                buttonFun("登 录");
                                thread.Join();
                                Thread.Sleep(2000);
                             
                            }
                            catch (Exception ex)
                            {
                               
                            }
                        }

                    }
                }).BeginInvoke(null, null);
               
            }

  • 相关阅读:
    Symmetric Order
    Red and Black
    Sticks(递归经典)
    Pascal Library
    cantor的数表
    OJ 调试技巧:VS2010 中 通过设置编译参数定义宏,无需修改源文件重定向标准输入输出
    strcmp
    最短周期串
    字母重排
    codeblocks 单步调试
  • 原文地址:https://www.cnblogs.com/LuoEast/p/10162202.html
Copyright © 2011-2022 走看看