zoukankan      html  css  js  c++  java
  • C# 多线程实例化 定时执行 实例化线程 刷新控件

    using System.Threading;
    namespace WindowsFormsApplication2
    {
        public partial class Form1 : Form
        {
            private delegate void FlushClient();
            public Form1()
            {
                InitializeComponent();
            }

            private void Form1_Load(object sender, EventArgs e)
            {
                Thread th = new Thread(new ThreadStart(BindThread));
                th.IsBackground = true;
                th.Start();
            }

            private void BindThread()
            {
                for (int i = 0; i < 4; i++)
                {
                    Thread chlidTh = new Thread(new ThreadStart(Start));
                    chlidTh.Start();
                }
            }

            public void Start()
            {
                while (true)
                {
                    ThreadFunction();
                    Thread.Sleep(4000);
                }
            }

            private void ThreadFunction()
            {
                if (this.dataGridView1.InvokeRequired)
                {
                    FlushClient fc = new FlushClient(ThreadFunction);
                    this.Invoke(fc);
                }
                else
                {
                    List<Person> per = new List<Person>();
                    per.Add(new Person("吴俊阳", 28));
                    per.Add(new Person("吴晓阳", 20));
                    this.dataGridView1.DataSource = per;
                }
            }

        }
    }

  • 相关阅读:
    【JavaScript】出现即使设置了ID也获取不到的可能原因与window.onload
    雄踞AppStore榜首的游戏&lt;别踩到白块儿&gt;源码分析和下载(一)
    WordPress公布新文章Email通知注冊用户
    BZOJ 1861 ZJOI2006 Book 书架 Splay
    Oracle Outline总结
    Matplot中文乱码完美解决方式
    Linux 在一个命令行上执行多个命令
    tophat
    echo输出到stderr
    随机森林
  • 原文地址:https://www.cnblogs.com/wujy/p/2851751.html
Copyright © 2011-2022 走看看