线程的启动,挂起,继续,停止
不多说,直接代码
命名空间
using System.Threading;
using System.Windows.Forms;
代码如下
Thread thread;
ManualResetEvent ma;
bool on_off = false;
bool stop = false;
// 创建线程
public void MyThreadStart()
{
thread = new Thread(Runtime);
thread.Start();
stop = false;
}
// 线程挂起
public void MyThreadPause()
{
on_off = true;
}
// 线程恢复
public void MyThreadContinue()
{
on_off = false;
ma.Set();
}
// 线程停止