avcalc (12) [Avatar] Offline
Hey Jim,

Is there any benefit of await before
textToSpeech.Speak($"Hello {Name}"); 
like so
await textToSpeech.Speak($"Hello {Name}"); 

Probably not, since it's the last statement in the method, is it correct?

Thank you,
Jim Bennett (88) [Avatar] Offline
The answer is it depends!

When I wrote that code the method wasn't async - it's something James Montemagno has added recently. If you call it without await it will speak when it's ready, and the method will end before the text is spoken. If you await it, then the method will only return after the text has been spoken.

So really it depends on your use case - if you want to wait for the text to be spoken before performing another action then yes you should await it.