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

  • 相关阅读:
    ASP.NET设置数据格式与String.Format使用总结(转)
    js 获取后台数据
    PowerDesigner设计的问题
    .Net设计模式
    js刷新
    UML使用问题
    Cookie揭秘
    数据库设计的十四个技巧
    jquery插件小试牛刀:文本框为空时默认文字显示,获得焦点后默认文字消失
    javascirpt 读写cookie
  • 原文地址:https://www.cnblogs.com/LuoEast/p/10162202.html
Copyright © 2011-2022 走看看