Justin Skiles
Justin Skiles

Reputation: 9513

How does the async keyword work with Azure Worker Roles?

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

Answers (1)

SLaks
SLaks

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

Related Questions