public class ThreadPoolTest
{
private void btnModifyPwd_Click(object sender, System.EventArgs e)
{
AddUserClass addUser = new AddUserClass();
System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(AddUserClass.AddUser));
}
}
public class AddUserClass
{
public static void AddUser(object stateObject)
{
//code
}
}
{
private void btnModifyPwd_Click(object sender, System.EventArgs e)
{
AddUserClass addUser = new AddUserClass();
System.Threading.ThreadPool.QueueUserWorkItem(new WaitCallback(AddUserClass.AddUser));
}
}
public class AddUserClass
{
public static void AddUser(object stateObject)
{
//code
}
}
只要我们点击btnModifyPwd按钮后,关掉web页面,程序仍将继续运行,改方法适用于大量更新数据的时候.