zoukankan      html  css  js  c++  java
  • 多线程更新form

    public void UIThread(MethodInvoker method)
    {
        if (this.InvokeRequired)
        {
            this.Invoke(method);
        }
        else
        {
            method.Invoke();
        }
    }
    
    public void UpdateUI()
    {
        this.UIThread(delegate
        {
            this.Label1.Text = "msg1";
            this.Label2.Text = "msg2";
        });
    }
    public void UpdateUI()
    {
        if (this.InvokeRequired)
        {
            this.Invoke(new MethodInvoker(delegate { UpdateUI(); }));
        }
        else
        {
            this.Label.Text = "msg1";
            this.Labe2.Text = "msg2";
        }
    }
    public void UIThread(MethodInvoker method)
    {
        if (this.InvokeRequired)
        {
            this.Invoke(method);
        }
        else
        {
            method.Invoke();
        }
    }
    
    public void UpdateUI()
    {
        this.UIThread(delegate
        {
            this.Label1.Text = "msg1";
            this.Label2.Text = "msg2";
        });
    }


     

        
    作者:wanglei_wan
        
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    20151104内置对象
    20151102adonet2
    20151029adonet1
    20151028c#4
    20151027c#3
    20151026c#2
    20151021c#1
    20151020sql2
    20151019sql1
    Codeforces Round #261 (Div. 2) C. Pashmak and Buses(思维+构造)
  • 原文地址:https://www.cnblogs.com/because/p/2698538.html
Copyright © 2011-2022 走看看