Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Await and async in ASP.NET app
Message
De
13/04/2016 05:14:55
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01634709
Message ID:
01634728
Vues:
36
>Hi,
>
>One of the features of my ASP.NET application is where a user enters some information and on Submit a stored procedure is called, which adds record(s) to the database. Then a method is called which sends email(s) to a distribution list. Sometimes the Email method/routine takes quite a bit of time (up to a minute) and the user has to wait for the Acknowledgement of submit. Recently I read a couple of on-line articles on Task Parallel Library and on await and async. I am still not 100% sure I understand these concepts (but it never in the past stopped me from implementing things I don't understand :)). So I am thinking of converting the method that sends emails to the "await" and "async" type method so that the user will get to the acknowledgement page faster, while the emails are being sent on another thread.
>
>Does it make sense?

To be clear: Do you want to simply notify the user that the request to send an email has been received - or that the email was successfully sent ?

If the former then you could just use a call to an async task without the await. In essence :
public bool EmailSendRequest(Email e)
        {
            SendEmail(e);
            return true;
        }

 public async Task SendEmail(Email e)
        {
            //Do whatever to send etc.
        }
If you wanted to notify the user on the actual success/failure of the send you could use something like SignalR to push to the user later....
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform