zoukankan      html  css  js  c++  java
  • 多线程更新UI 武胜

    private delegate object GetButtonTagDelegate(ref Button b);

    private object GetButtonTag(ref Button b)
            {
                if (InvokeRequired)
                {
                    return Invoke(new GetButtonTagDelegate(GetButtonTag), new object[] {b});
                }

                return b.Tag;
            }

    private delegate int GetComboBoxSelectedIndexDelegate(ref ComboBox cb);

    private int GetComboBoxSelectedIndex(ref ComboBox cb)
            {
                if (InvokeRequired)
                {
                    return (int) Invoke(new GetComboBoxSelectedIndexDelegate(GetComboBoxSelectedIndex), new object[] {cb});
                }

                return cb.SelectedIndex;
            }

    private delegate void ButtonPerformClickDelegate(ref Button b);

    private void ButtonPerformClick(ref Button b)
            {
                if (InvokeRequired)
                {
                    Invoke(new ButtonPerformClickDelegate(ButtonPerformClick), new object[] {b});
                }
                else
                {
                    b.PerformClick();
                }
            }

    private delegate void UpdateCountdownProgressBarDelegate(ref ProgressBar pb, int delay, int elapsed);

    private void UpdateCountdownProgressBar(ref ProgressBar pb, int delay, int elapsed)
            {
                if (InvokeRequired)
                {
                    Invoke(new UpdateCountdownProgressBarDelegate(UpdateCountdownProgressBar), new object[] {pb, delay, elapsed});
                }
                else
                {
                    pb.Minimum = 0;
                    pb.Maximum = delay;

                    if (elapsed < delay)
                    {
                        pb.Value = delay - elapsed;
                    }
                    else
                    {
                        pb.Value = 0;
                    }
                }
            }

    private delegate bool GetCheckBoxCheckedDelegate(ref CheckBox cb);

    private bool GetCheckBoxChecked(ref CheckBox cb)
            {
                if (InvokeRequired)
                {
                    return Convert.ToBoolean(Invoke(new GetCheckBoxCheckedDelegate(GetCheckBoxChecked), new object[] {cb}));
                }

                return cb.Checked;
            }

    private delegate void AddComboBoxItemDelegate(ref ComboBox cb, string item);

    private void AddComboBoxItem(ref ComboBox cb, string item)
            {
                if (InvokeRequired)
                {
                    Invoke(new AddComboBoxItemDelegate(AddComboBoxItem), new object[] {cb, item});
                }
                else
                {
                    cb.Items.Add(item);
                }
            }

  • 相关阅读:
    [jQuery]无法获取隐藏元素(display:none)宽度(width)和高度(height)的新解决方案
    < meta > 元素(转)
    认识圣杯布局和双飞翼布局(转)
    条件注释判断浏览器版本<!--[if lt IE 9]>(转载)
    Kubernetes日志采集Sidecar模式介绍
    filebeat常见配置项梳理
    debin 安装容器安装工具 ​apt-get install telnet
    python-study-账号登录验证
    老板的三个忠告
    有趣的程序
  • 原文地址:https://www.cnblogs.com/zeroone/p/2681153.html
Copyright © 2011-2022 走看看