await method inside HttpTaskAsyncHandler

344 views Asked by At

I have an asynch handler which inherits from HttpTaskAsyncHandler. At some line inside that handler I have a code which calls an async methods(decorated with the 'async' keyword) which executes a commands in documentDB and returns a task like in the following example: https://learn.microsoft.com/en-us/azure/cosmos-db/documentdb-dotnet-application .

Originally I had a regular generic handler, but the link shows that they changed the controller to be async so I changed my handler to inherit from HttpTaskAsyncHandler. Now, I feels like there is too much/duplicate multi threading here, my handler is now async but also inside the handler I await a method which works with documentDB api(insert operation).

Am I doing two async operation here? One because the handler is async and one because the documentDB method call is async?

1

There are 1 answers

1
Vishal Patwardhan On

Am I doing two async operation here? YES.

what does the code mean await asd(); it commits to produce the desire result once that asynchronous operation being completed & if there are code beneath it further nature of code execution will become synchronous.