I have an application in C # that when displaying a certain window performs several operations in its Load () method, since several tasks take some time and I have tried to load animation but I could not, and tried to put the Load method () of the asynchronous form but it still does not work, my load method is this:
private async void FormMembresia_LoadAsync(object sender, EventArgs e)
{
pcloader.Visible = true;
await DescNodoLoading();
pcloader.Visible = false;
}
From here I call the method DescNodoLoading () which is the one that executes the tasks (Consult an API, local files and finally graph), it is a method like this:
private Task<Boolean> DescNodoLoading()
{
return Task.Run(() =>
{
BeginInvoke(new Action(() =>
{
//CODE
}
}
}
When opening the window it does not finish loading 100% and it is blocked until the DescNodoLoading () method task finishes, it does not even show the load gif because it hangs until the method ends, could someone tell me why? does not the function run in the background while the form is created and shows me the load gif which is what I think should happen?