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

        }
    }

  • 相关阅读:
    设定cookie 获取cookie数据的转换
    cookie cookie的获取
    常见的请求方式 json字符串
    请求报文和响应报文
    http协议
    php分页查询 子查询
    MAC 地址为什么不需要全球唯一
    ceph分布式存储简介
    一文看懂为什么边缘计算是大势所趋
    真香!Windows 可直接运行 Linux 了
  • 原文地址:https://www.cnblogs.com/wujy/p/2851751.html
Copyright © 2011-2022 走看看