Application.Run()
在没有对话框的情况下调用后,如何调用胎面/表单的消息循环?原因是我想准备(并稍后显示)一个可单击的对话框,即使在主应用程序中显示了模态对话框。
static Form1 dialog;
private static void CreateDialog(object obj)
{
dialog = new Form1();
Application.Run();
}
static void Main(string[] args)
{
var thread = new Thread(CreateDialog);
thread.Start();
Thread.Sleep(2000); //only for demonstration
dialog.Invoke((Action)dialog.Show); //InvalidOperationException: need window handle first
}