asp.net线程是否需要关闭,如何关闭
发布网友
发布时间:2022-04-27 14:57
我来回答
共1个回答
热心网友
时间:2022-04-27 16:27
private void display()
{
while (ff == true)
{
}
}
void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "开始监控")
{
ff=true;
Thread a = new Thread(new ThreadStart(display));
a.Start();
button1.Text = "停止监控";
}
else
{
a.Abort();
serialPort1.Close();
button1.Text = "开始监控";
ff = false;
}
}