线程中timer的内容不启动
private void button6_Click(object sender, EventArgs e){
t = new Thread(new ThreadStart(OpenTime));//调用openTime方法
t.Start();
// 开启线程
}
private void OpenTime() {
MessageBox.Show("11");
timer3.Start();
}
断点能走过timer3.Start();但是不执行timer3_Tick 内的内容,请问为什么啊 --------------------编程问答-------------------- 有人帮忙看看吗 --------------------编程问答--------------------
--------------------编程问答-------------------- 估计是没有enalbe吧 --------------------编程问答-------------------- 还是不行。。。。 --------------------编程问答-------------------- 我是win7 64 系统
private void OpenTime() {
MessageBox.Show("11");
timer3.Enalbe=true;//加上这句试试
timer3.Start();
}
用的是VS 2008 能不能与平台性有关? --------------------编程问答-------------------- 我用线程的原因是 timer3_Tick 内有 Thread.Sleep(5000);有线程休眠
这样我的主程序就卡住了。。。关闭线程按钮根本点不了,只能强行关闭程序
所以才加的线程。加完线程还无法运行 timer3_Tick
--------------------编程问答-------------------- 是Winform的那个Timer吧
timer3.Start();
后面加上
Application.Run();
能跑,不保证没有潜在问题。
--------------------编程问答-------------------- 好使了,不过的确有潜在问题,例如 我开启,然后立刻关闭,再开启就开不开了,为什么啊
private void button7_Click(object sender, EventArgs e)
{
guanbiXian();
}
private void guanbiXian() {
timer3.Stop();
t.Abort();
t = null;
} --------------------编程问答--------------------
补充:.NET技术 , C#