zoukankan      html  css  js  c++  java
  • Control.BeginInvoke 和 Delegate.BeginInvoke 备忘

    代码段1:

    string str = "0";
                MessageBox.Show(str, "[ 温馨提示 ]");
                this.BeginInvoke(new Action(() =>
                    {

                        for (int i = 0; i < 5; i++)
                        {
                            Thread.Sleep(1000);
                        }
                        MessageBox.Show(str, "[ 温馨提示 ]");
                    }));
                str = "1";

    两者之间的区别:

    Control.BeginInvoke:仍然是在UI线程,也就是说,界面仍然会卡住,但是这个函数将会执行结束,也就是说,str = "1";会被执行的。这就是和Control.Invoke 的区别。

    Delegate.BeginInvoke:这个就是从ThreadTool 重新创建一个线程了,没什么好说了。

  • 相关阅读:
    转: PHP的"::"、"->"和"=>"的区别
    PHP命名空间
    PHP+MySQL数据库编程的步骤
    SQL基础
    Mysql的CMD操作
    Apache服务器配置
    【网关】SpringCloud-Gateway
    Oracle表分区
    MongoDB---分片
    MongoDB-BSON
  • 原文地址:https://www.cnblogs.com/sofire/p/1700719.html
Copyright © 2011-2022 走看看