Relative Content

Tag Archive for c#asynchronousasync-await

different thread with async/await

I’ve heard a lot about how a new thread is not created with async awiat. I decided to check what would happen if there was an while(true) in the main function and the asynchronous function.

Call async method from another async method

I am trying to run an asynchronous method from another asynchronous method and make sure that both of them complete successfully. Like in the example below I am adding a delay of 1000ms in Function1() and a delay of 3000ms in Function2(), meaning the Main() task should complete first. Also, I am using .Net6.0 to able to run this snippet.

fire-and-forget async function call deadlocks

I have a controller action which must run some tasks that don’t need to be awaited to return a response which is why I’m firing-and-forgetting those functions. However these functions are deadlocking hence never completing.

why async does not return control to the caller after hitting await

I’m trying to understand how async/await works in C#, specifically related to the thread behavior. I’ve been reading Stephen Cleary’s blog post on async and await (https://blog.stephencleary.com/2012/02/async-and-await.html), and one part of the documentation confuses me: