I want to add a loading form in a function
private async void Test()
{
// 1, show loading form
await DoTest();
//2, close loading form
}
the loading form need to block the main form, at first, I try to run the form ShowDialog()
, but it will stop the following function
What's the best idea to do this?
My final solution:
private async void Test()
{
// 1, show loading form
var loadingScreen = new LoadingForm();
Task.Factory.StartNew(delegate
{
Invoke((Action)delegate
{
loadingScreen.ShowDialog(App.Views.Forms.RobotActiveView);
});
});
await DoTest();
//2, close loading form
Invoke((Action)delegate
{
loadingScreen.Close();
});
}