Tuesday, July 28, 2009

I am using thread in ASP.NET with C#?

I want to send mail through using threads in ASP.NET with C#, but if any error in thread function than threads aborted, I have used try catch for this but no response, no code execute if error


try


{


// send mail code


}


catch (Exception e)


{


// write into log file


}





but no log file updated





please help me

I am using thread in ASP.NET with C#?
From my understanding, the thread pool has by default 25 threads(point to


note timers use the thread pool) that you can use. After all these threads


are used up the next request will wait until one of the threads becomes


free. The Pool is created the first time you





A) a timer is registered


B) you invoke the Threadpool.queueuserworkitem





To use the threadpool you need to call the Threadpool.queueuserworkitem


with a callback delegate with an Object argument that will process your


work.





System.Net.Mail.MailMessage message = new system.Net.Mail.MailMessage();


message.To.Add("luckyperson@online.mic...


message.Subject = "This is the Subject line";


message.From = new System.Net.Mail.MailAddress("From@online...


message.Body = "This is the message body";


System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("yoursmtphost...


smtp.Send(message);


No comments:

Post a Comment