Marking a method with the
async
keyword doesn't magically make it run asynchronously. It doesn't spin up any threads in the background. All it does is enable the use of the
await
keyword within that method, so that you can execute IO-bound code without blocking the current thread.
Calling
Thread.Sleep
from an
async
method will still block the current thread. Instead, call
await Task.Delay(timeToWait);
:
LoadingWindow.Show();
await Task.Delay(5000);
TestForm.Showdialog();
But as honey said, this isn't going to solve your real problem. You need to find out why your form is taking so long to load, and change the loading logic so that it doesn't block the UI thread whilst it's loading.