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

        }
    }

  • 相关阅读:
    bzoj 2599
    bzoj 3697
    poj 1741
    bzoj 2741
    bzoj 5495
    bzoj 3261
    网络流24题——骑士共存问题 luogu 3355
    网络流24题——数字梯形问题 luogu 4013
    bzoj 3998
    网络流24题——魔术球问题 luogu 2765
  • 原文地址:https://www.cnblogs.com/wujy/p/2851751.html
Copyright © 2011-2022 走看看