标签:
C#里面实现多线程的有很多,下面是自己总结的几个实例。时间比较紧,也就给出一些实例。
private void button3_Click(object sender, EventArgs e) { Thread thread = new Thread(new ThreadStart(new Action(() => { string name = button2.Text.Trim(); DoSomeThing(name, button3); }))); thread.Start(); } private void DoSomeThing(string name, Button btn) { if (btn.InvokeRequired) { btn.Invoke(new EventHandler(delegate { btn.Text = name; })); } else btn.Text = name; }
string name = "guozhijian"; ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object o){ MessageBox.Show(name);
标签:
原文地址:http://www.cnblogs.com/Sind-Xiao/p/4843231.html