给大分:主线程,取子线程结果错乱的问题 线程线程安全thread 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Random rd = new Random();这个放在函数外面。作为成员变量。 caozhy:按您的方法,还是一样的不行呀。 bool stopped=false;//委托方法 private void SetText(string text) { if (this.textBox1.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetText); this.Invoke(d, new object[] { text }); } else { this.textBox1.Text = text;if(stopped){this.label2.Text = this.label2.Text + "结果:" + this.textBox1.Text + System.Environment.NewLine;} } } //停止按钮 private void button2_Click(object sender, EventArgs e) {stopped=true; this.doYaohao.Abort(); } *****************************************************************************签名档: http://feiyun0112.cnblogs.com/ 在线程启动前,还需要:stopped=true;谢谢 feiyun0112 Winform如何记住修改密码,使得下次登陆密码为这次的修改密码啊? 登陆不区分大小写。 一个奇怪的问题,请求帮助!!! 三层 C/S 程序的问题 能在子线程里关闭主程序吗? 200分求助使用.net(C#)实现b/s结构软件的具体过程? 中国程序员博客网正式开通,域名诚征意见 不需要帐户密码,如何注销本次windows登陆? 请教个问题思路 Session与Application.Contents的区别? C# FormClosing 为什么要点两次“是”才会退出系统这是为什么? 求帮:NPOI设置Excel单元格背景及合并问题?
//委托方法
private void SetText(string text)
{
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
if(stopped)
{
this.label2.Text = this.label2.Text + "结果:" + this.textBox1.Text + System.Environment.NewLine;
}
}
} //停止按钮
private void button2_Click(object sender, EventArgs e)
{
stopped=true;
this.doYaohao.Abort();
}
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/