如何打开MessageBox,使其保持打开状态,直到任务完成,然后将其关闭。
我打算在其中插入加载动画。
我需要以某种方式使您无法仅通过代码单击就将其关闭。
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;
}
});
}
});
答案 0 :(得分:2)
您需要创建自己的窗体/窗口,该窗体/窗口可以模仿消息框的外观,但是您可以更好地控制它(例如,在任务完成后实施关闭事件)。标签和几个按钮应该不会花费太长时间,并且将在以后的项目中有用!
答案 1 :(得分:0)
如果要在UI上执行操作时显示繁忙的光标,可以使用-
beginning with strings............[some string] ending with some strings....
如果要显示动画,请参考this