This is a good time to use multithreading in ASP.NET MVC and how is it implemented?

I want a specific action request to trigger a set of email notifications. The user does something, and he sends emails. However, I do not want the user to wait for a response to the page until the system generates and sends emails. Should I use multithreading for this? Will this work even in ASP.NET MVC? I want the user to receive a response to the page, and the system simply finishes sending emails at its own pace. I'm not even sure if this is possible or how the code will look. (PS: Please do not offer me an alternative solution for sending email, you do not have time for such a reconfiguration.)

+3
source share
6 answers

SmtpClient.SendAsyncprobably better than manual streaming, although multithreading will work just fine with the usual caveats.

http://msdn.microsoft.com/en-us/library/x5x13z6h.aspx

As other people have pointed out, success / failure cannot be deterministically indicated when the page returns before the submission is actually completed.

A few observations when using asynchronous operations:

1) , . . SendAsync(), , , , , . , , .

, , , , ? , , , - , . . , async , .

2) Threading ASP.Net , ThreadPool, , .. , , , . , , .

3) Threading/Async , . , (, ), . , .

. ASP.Net .

. SO: ASP.NET

+2

, , MessageQueue (, MSMQ) . asp.net , , . , , ( ):

• . , . • . , . • , . • , .

+1

, SQL Server SQL Server Database Mail. Windows, , , ASP.Net.

+1

, .

, , - , , ? - . , .

0

, - , - , - .

0

Source: https://habr.com/ru/post/1769565/


All Articles