How can I open a MessageBox , keep it open until a task finishes, and then close it.
I plan to insert a loading animation inside it.
I need to somehow make it that you cannot close it by clicking it, just through the code.
var t = Task.Run(() =>
{
MessageBox.Show("Loading!");
CycleValue = 0;
while (CycleValue < noOfCycles && buttonStartStop.Text == "Stop")
{
this.Invoke((MethodInvoker)delegate
{
gm.NextState();
CycleValue++;
if (CycleValue == noOfCycles)
{
buttonStartStop.Text = "Start";
buttonRandomise.Enabled = true;
buttonReset.Enabled = true;
}
});
}
});