asp.net 多线程
一般情况下,asp.net的代码是自上而下运行的,但有的情况需要多线程,比如发邮件这种操作,下面给出实现方案
定义类
public class ThreadWithEmailState
{
public string subject;
public string content;
public string receiver;
public string ccs;
public ThreadWithEmailState(string subject, string content, string receiver,string ccs)
{
this.subject = subject;
this.content = content;
this.receiver = receiver;
this.ccs = ccs;
}
public void ThreadProc()
{
RISEmail.send(subject, receiver, content, ccs);
}
}
调用
ThreadWithEmailState tws = new ThreadWithEmailState(emailSubject, content[1], receiver, ccs);
Thread t = new Thread(new ThreadStart(tws.ThreadProc));
t.Start();
posted on 2013-05-31 13:40 kenny jiang 阅读(393) 评论(0) 收藏 举报
浙公网安备 33010602011771号