Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Await and async in ASP.NET app
Message
From
13/04/2016 13:41:44
 
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01634709
Message ID:
01634750
Views:
26
>>>>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....
>>>
>>>Therefore it looks like "await" is not necessary.
>>
>>If you wanted code to run after the SendEmail() task completed you could use await and add that code after the call. But to use 'await' the enclosing method must be an async task.....
>>
>>> I am not at all familiar with SignalR, will Google it.
>>
>>In simple terms SignalR would allow your client side to listen for messages sent by the server so the browser could be sent a notification if the email send failed
>
>Please confirm that I understand it correctly. If I DO NOT use await the code runs and is forgotten. But if some code has to run AFTER the process (e.g. email procedure ) I have to have AWAIT and put the follow-up code after AWAIT? Correct?

Yes - and, as before, the method containing the await must itself be asynchronous....

>As far as SignalR, it sounds very clear the way you explain it. I am sure it will be not so simple to implement.

Not difficult at all (and fun !)

>Thank you very much.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform