首先在项目头添加:using System.Threading;
一、启动线程
1 .在按钮中启动线程
ThreadStart threadStart = new ThreadStart(Calculate1);//通过ThreadStart委托告诉子线程执行什么方法
Thread thread = new Thread(threadStart);
thread.Start();//启动线程1
2 .添加子线程函数
public static void Calculate1()
{
//添加所需要的检测代码
}
二、关闭线程
thread.Abort();//调用Thread.Abort方法试图强制终止thread线程
其他知识点:
子线程与主线程共用变量:
public static HTuple hv_ExpDefaultWinHandle;