110,561
社区成员
发帖
与我相关
我的任务
分享
System.Threading.Thread trd; //定义全局变量
private void startBtn_Click(object sender, EventArgs e)
{
trd = new Thread(new ThreadStart(this.attackThread));//创建线程
trd.IsBackground = true;
if (startBtn.Text == "开始" && trd.ThreadState==ThreadState.Unstarted)
{
timer2.Start();
startBtn.Text = "暂停";
trd.Start();
}
else if (startBtn .Text =="暂停" && trd.ThreadState==ThreadState.Running)
{
trd.Suspend();//发VS2005提示 线程目前未运行;无法使其挂起。
startBtn.Text = "开始";
MessageBox.Show("停止动作!");
}
}
System.Threading.Thread th; //定义全局变量
private void startBtn_Click(object sender, EventArgs e)
{
Thread trd = new Thread(new ThreadStart(this.attackThread));//创建线程
trd.IsBackground = true;
if (startBtn.Text == "开始" && trd.ThreadState==ThreadState.Unstarted)
{
timer2.Start();
startBtn.Text = "暂停";
trd.Start();
}
else if (startBtn .Text =="暂停" && trd.ThreadState==ThreadState.Running)
{
trd.Suspend();//发VS2005提示 线程目前未运行;无法使其挂起。
startBtn.Text = "开始";
MessageBox.Show("停止动作!");
}
}