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

  • 相关阅读:
    mysql索引
    mysql中的事务
    mysql的各种join连接
    java集合-LinkedList源码分析
    java集合(二)-ArrayList源码分析
    java集合(一)-集合概述
    java并发(五)-重排序、 happens-before
    vue引入百度地图 --BMap is not defined ,eslint BMap报错
    红星美凯龙前端面试内容总结
    vue父子组件钩子函数的执行顺序
  • 原文地址:https://www.cnblogs.com/zeroone/p/2681153.html
Copyright © 2011-2022 走看看