asp.net mvc - Is this MVC Fire and Forget approach bad Design? -



asp.net mvc - Is this MVC Fire and Forget approach bad Design? -

i have controller's action performs task , @ end, sends confirmation e-mail user. e-mail part of not important, not want create action break if sending of e-mail throws exception, , don't want http response wait e-mail sent either. want fire , forget thing. in nutshell, how approached it:

public async task<actionresult> myaction(){ // stuff await dostuff(); thread sendemailthread = new thread(sendemail); sendemailthread.start(); homecoming result; } private async void sendemail(){ await smtpclient.sendmessageasync(); }

approach proper?

it not thought start new thread whenever new email arrived.

alternative approach (especially email)

we run background scheduling scheme behind application. example, quartz.net

then queue email in queue (or database), , allow background thread pick queue (or database), , preform process.

by doing so, can re-send emails if smtp has error.

asp.net-mvc email asynchronous fire-and-forget

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -