Avanade/Beef

Feature Request - Asynchronous Call Integrity

JamieAitchison opened this issue · 2 comments

DataService and Data layers do not currently include async/await keywords for generated code. this leaves a break in the async flow and can cause some unintended threading issues.

Can Beef generation be changed to have "public async Task" for Async methods and await Data[Svc]Invoker.Current.InvokeAsync for the invoker calls of Data and DataSvc classes please?

async/await are only added (this is the intension, please advise if it doesn't) where the result is needed in the context of that method; otherwise, the Task is returned to avoid the overhead of the compiler adding a state machine, etc. See StackOverflow: https://stackoverflow.com/questions/35201881/should-i-use-async-await-for-every-method-that-returns-a-task?msclkid=fe4d3b87d0ab11ecadb637dc8c754314

I concur. Did a bunch of reading and also looked properly and the invoker implementations.
The articles I was reading that lead me to wonder about Task usage was this one.
https://medium.com/@deep_blue_day/long-story-short-async-await-best-practices-in-net-1f39d7d84050

I then found a very similar article to the one you've shared and .
https://stackoverflow.com/questions/33054199/can-we-turn-async-methods-into-expression-body

In the end what I was really wondering about was the difference in invoker usage between the manager invoker and the data and datasvc invoker implementations.