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

  • 相关阅读:
    使用South时候由于两个相同id的文件引起的问题
    Python os模块
    Ubuntu的关机重启命令知识
    [BUGFIX]__import_pywin32_system_module__
    Django生产环境的部署-Apache-mod_wsgi
    我是如何将linux用在开发环境中的
    php抽奖概率算法
    PHP接收IOS post过来的json数据无法解析的问题
    python apache下出现The _imaging C module is not installed
    php 打印
  • 原文地址:https://www.cnblogs.com/zeroone/p/2681153.html
Copyright © 2011-2022 走看看