Questions about asynchronous programming

I was wondering in a rich gui application, what would happen if an awaited method was finished and ready to go back and continue the rest of the code after the await while at the same time a control on the ui was being triggered and another method needed to be ran. What would have priority in that scenario?

Also if I have a method that calls an api and that request/response takes ~250ms and I needed to call this api thousands of times more, could I use asynchronous programming to increase the performance and reduce that time it takes to make those api calls? Could I wrap the api call in a TaskCompletionSource and call it thousands of times in a for loop and do a Task.WhenAll() so that they can be performed all at once instead of synchronously (call api then wait for response then loop to make the next api call)?

submitted by /u/NetFutility
[link] [comments]

Leave a Reply