I’m playing with Azure Worker Roles. When calling asynchronous WinRT methods and using the await keyword, the service execution is ended. I’m guessing this is because await returns control to the caller, which is something up the chain in the service internals. Maybe the caller isn’t expecting Run() to return control until it is finished executing and assumes the service is completed or faulted?
I’m not sure, does anyone know if async is intended to be used with Azure Worker Roles?
Your guess is exactly correct.
At some point in the call stack, you need to explicitly wait (and block) until the operation is finished, by calling
.Wait()on theTaskfrom anasyncmethod.You should probably do this in or near the root
Run()method.