zoukankan      html  css  js  c++  java
  • C#多线程进度条

     public class ZyjProgressBar : System.Windows.Forms.ProgressBar
        {
            //用于跨线程访问控件的委托
            private delegate void deleByControl(int v);
    
            //用于执行的任务
            public Action Task { get; set; }
            private Thread taskThread;
            private deleByControl setValueDele;
    
    
            public ZyjProgressBar()
            {
                //初始化线程
                this.taskThread = new Thread(StartTask);
                this.taskThread.IsBackground = true;
                //初始化委托
                this.setValueDele = new deleByControl(AddValue);
    
            }
    
            private void StartTask() {
                this.Task();
            }
    
            /// <summary>
            /// 增加进度条的进度
            /// </summary>
            public void AddValue(int value)
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(this.setValueDele, 3);
                }
                else
                {
                    this.Value += value;
                }
            }
        }
    致读者:感谢你阅读本文,请随手点击右下角的推荐或分享,谢谢!
  • 相关阅读:
    erl_0012 timer:tc 测试模块函数调用运行耗时
    erl_0011 erlang 定时器相关
    erl0010
    erl0009
    erl0008
    erl0007
    erl0006
    erl0005
    开开心心过生活、踏踏实实做技术
    Android-理解Intent
  • 原文地址:https://www.cnblogs.com/yzeng/p/3891272.html
Copyright © 2011-2022 走看看