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

        }
    }

  • 相关阅读:
    hbase权威指南PDF下载
    流畅的pythonPDF下载
    现代操作系统PDF下载
    Kafka权威指南PDF下载
    java核心技术卷1PDF下载
    计算机网络自顶向下方法PDF下载
    git gitlab 部署
    MySQL 索引、事务与存储引擎(详细解读)
    QT: Layout布局间消除间隙(修改layout内置参数)
    数据结构---归并排序
  • 原文地址:https://www.cnblogs.com/wujy/p/2851751.html
Copyright © 2020-2023  润新知