关于winForm的多线程。实现C#WinForm 登录日志,系统日志,操作日志。

来源:互联网 发布:淘宝旺旺客服链接生成 编辑:程序博客网 时间:2024/05/16 06:25
public partial class Form1 : Form
{
private delegate void FlushClient();//代理
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
FlushClient fc=new FlushClient(ThreadFunction);
fc.BeginInvoke(null,null);
}
private void ThreadFunction()
{
while (true)

{

// 线程一定是死循环

//需要写的判断就在这里写。比如登出。LogOut

this.textBox1.Text = DateTime.Now.ToString();
Thread.Sleep(1000);
}
}
}
原创粉丝点击