private bool IsRun; private void stop_Click(object sender, EventArgs e) { IsRun = false; StreamWriter sw = File.AppendText(@"d:\myserver.txt"); sw.WriteLine(string.Format("停止:启动时间{0}", DateTime.Now)); sw.Close(); }
private void begin_Click(object sender, EventArgs e) { IsRun = true; while (IsRun) { try { StreamWriter sw = File.AppendText(@"d:\myserver.txt"); sw.WriteLine(string.Format("启动:启动时间{0}", DateTime.Now)); sw.Close(); } catch (Exception ex) { throw ex; }
System.Threading.Thread.Sleep(10000); } } }
当按下按钮beigin后。。为什么stop按钮无法被按下。。好像假死的状态?????????????
- 2 回答
- 0 关注
- 328 浏览
添加回答
举报
0/150
提交
取消