Reputation: 9513
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?
Upvotes: 2
Views: 976
Reputation: 887509
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 the Task
from an async
method.
You should probably do this in or near the root Run()
method.
Upvotes: 5