Hi,
I've got a class that sends a confirmation email from a web app upon checkout. When the user click's the "process order" button, the app will finalize the order in the database, fire off a confirmation email and generate a confirmation page. I used System.Net.MailMessage and created a confirmation email and it works well.
The only problem is when there are occasional problems with the mail server. I put the confirmation email sending method in a try/catch block so the rest of the order goes through, but the user still doesn't get their confirmation mail. The mail server (google apps, surprisingly enough) doesn't seem to have 100% uptime.
So I'd like to try to resend the email in the event of a failure, but I can't wait too long because the confirmation page needs to be sent back to the user.
This is best done by creating a new thread to do the work of sending ( and possibly resending) the email while the main thread prepares the confirmation page.
So, what's the best way to spawn a new thread from a web app? I don't need to ever rejoin the threads and want to make sure that there are no memory leaks.
I could use delegate.BeginInvoke, use a ThreadPool thread, or just use new Thread().
Which is best?
Thanks
Go to the complete details ...