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 重新创建一个线程了,没什么好说了。

  • 相关阅读:
    1.14 作业
    1.12作业
    1.9 作业 矩阵转置与输出九宫格
    1.8 作业
    1.7 作业 打印菱形
    1.5 作业
    1.4作业 不同的年龄,不同的问候语
    PHP语言 -- 发起流程
    PHP语言 -- 新建流程
    PHP语言 -- 权限
  • 原文地址:https://www.cnblogs.com/sofire/p/1700719.html
Copyright © 2011-2022 走看看