asp.net多线程带参数操作
在项目中用到了邮件发送,因为发送邮件这个过程很慢所以返回数据有点延迟,就考虑到了线程,
代码如下:
这是带参数的线程
//发送邮件
Thread th = new Thread(new ParameterizedThreadStart(new Maticsoft.BLL.job_company_basicinfo().Post_Email));
th.Start(modelapp.comid);
Post_Email 参数必须是object类型
另一种方法
var obj = neW MyThread("info");
var t3 = neW Thread(obj.ThreadMain)氵
t3.start();
public class MyThread
{
private string data ;
public MyThread(string data)
{
this.data = data;
}
public void ThreadMain()
{
Console..WriteLine("Running in a thread, data: (0)", data);
}
}