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);
               
            }

  • 相关阅读:
    testDecoration
    python装饰器详解
    开闭原则, 对扩展开放、对修改关闭
    使用元类 编写ORM
    Python 实现累加计数的几种方法
    python 查找目录下 文件名中含有某字符串的文件
    android应用程序的混淆打包规范
    自定义Tabs
    android-Service
    Loader异步装载器
  • 原文地址:https://www.cnblogs.com/LuoEast/p/10162202.html
Copyright © 2011-2022 走看看