RuS*_*uSh 5 asp.net multithreading threadpool
我的应用程序是在iis 6上运行的asp.net 3.5(Windows 2003)此应用程序每天为1000个用户提供服务(在线100-500个用户).
我想每周向客户发送一封电子邮件简报.
每次大约200,000封电子邮件.
这是我正在使用的代码:
ThreadPool.QueueUserWorkItem(new WaitCallback(AsyncProcessMailerQueue), null);
private static void AsyncProcessMailerQueue(object data)
{
for (int i=0;i<users.count ; i++)
{
MailMessage message = new MailMessage();
.......
SmtpClient smtpClient = new SmtpClient();
smtpClient.Send(message);
}
}
Run Code Online (Sandbox Code Playgroud)
在本地测试(在我的开发机器上)时,我看到应用程序运行速度慢了很多.
我在这里看到其他帖子谈论ThreadPool vs Thread但似乎没有人确定哪个更好.
按优先顺序排列:
Thread t = new Thread(new ThreadStart(DoWork));