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;
namespace 多线程访问
{
public partial class Form1 : Form
{
private delegate void client();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Thread threadnew = new Thread(threadflush);
threadnew.IsBackground = true;
threadnew.Start();
}
private void threadflush()
{
while (true)
{
Thread.Sleep(1000);
threadfunction();
}
}
private void threadfunction()
{
if (textBox1.InvokeRequired)
{
client fc = new client(threadfunction);
this.Invoke(fc);
}
else
{
textBox1.AppendText("1");
}
}
}
}
原文地址:http://hi.baidu.com/gwj6396668/item/773ce30f181375d01ef04661
C#winform控件多线程访问
最新推荐文章于 2023-01-15 19:11:51 发布