Why the output is like this?
123
XYZ
As per my understanding, it should print XYZ first, as I am not writing await in line no. 50
Why the output is like this?
123
XYZ
As per my understanding, it should print XYZ first, as I am not writing await in line no. 50
2
Answers
Thread.Sleep
waits synchronously. Your thread simply stops there for 10 seconds, since there’s nothing telling it to go back to the caller. Tryawait Task.Delay(10_000)
instead.You need set PrintDate method => public static async void and on her body set => await Test1(); because Test1 method was async