Reputation: 45
I'm using Microsoft.WindowsAzure.Storage.Table
and couldn't figure out what's the difference between async methods and regular methods, for example CloudTable.Execute
and CloudTable.ExecuteAsync
. When and why should I use each of them? Is this even related to storage design and the module I'm using or am I misunderstanding the concept of async methods (I'm new to c# and Azure)?
Edit: If I should always use async methods, why are regular methods implemented, available, and moreover used in most Azure table storage guides?
Thanks in advance!
Upvotes: 1
Views: 694
Reputation: 4012
It's not just the table storage but any service that implements async operation should be used. We use async to off load the main thread and shift the task on the background. The main thread is ready to take more requests while background task is getting completed. Once completed it will bring back the control to the main thread. If you don't use async you get info problem called resource starvation where your request pool start growing and eventually your application hangs up .
Look into the following link and it explains in details. Synchronous I/O antipattern
Upvotes: 0
Reputation: 1047
Basically when using the CloudTable.ExecuteAsync the compiler generates a state machine in the background, so you can avoid performance bottlenecks and enhance the overall responsiveness of your application.
Upvotes: 2