zoukankan      html  css  js  c++  java
  • C# 控件的BeginInvoke方法演示程序

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;
    using System.Diagnostics;

    namespace WindowsFormsApplication12
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            p rivate void button1_Click(object sender, EventArgs e)
            {
                Thread myThread = new Thread(new ThreadStart(threadfun));
                myThread.Start();
            }

            p rivate void threadfun()
            {
                MethodInvoker mi = new MethodInvoker(this.invokefun);
                for (int i = 0; i < 100; i++)
                {
                    this.BeginInvoke(mi);
                    Thread.Sleep(30);
                }
            }

            p rivate void invokefun()
            {
                if (progressBar1.Value < 100)
                {
                    progressBar1.Value += 1;
                }
            }
        }
    }
     

    本例源代码下载

  • 相关阅读:
    httprunner-2-linux下搭建hrun(下)
    Docker学习3-简单shell脚本安装mysql5.7与docker小技巧
    功能测试--聊天功能测试&微信聊天
    Fiddler抓包3-查看get与post请求
    面向对象--继承
    Mybatis入门
    Maven基础
    Cookie&Session
    Redis应用
    Redis概念和安装
  • 原文地址:https://www.cnblogs.com/hackpig/p/1668475.html
Copyright © 2011-2022 走看看