I have this test methods,
private async Task<int> TestOnly()
{
await Task.Delay(10000);
using (StreamWriter sw = File.AppendText(@"asyncTest.txt"))
{
sw.WriteLine($"2 Written TestOnly().");
}
return 100;
}
private async Task TestAgain()
{
await Task.Delay(0);
using (StreamWriter sw = File.AppendText(@"syncTest.txt"))
{
sw.WriteLine($"1 Written here TestAgain().");
}
}
Private async Task Refresh()
{
await TestOnly();
await TestAgain();
}
If I call the Refresh(), what I am expecting that in syncTest.txt
, the text 1 Written here TestAgain().
will print first than 2 Written TestOnly().
because the TestOnly()
method awaiting 10 seconds before it writes into the asyncTest.txt
. But when I run, it waits for it. Why is that?