class Program { static void Main(string[] args) { Form form = new Form(); form.Show(); Console.ReadLine(); } } 以上代码中的form显示后就一直有等待图标,似乎消息循环阻塞了 请教如何正确在命令行中创建非模态窗口
你说的对,下面代码可以工作
class Program
{
public static void ThreadProc(object arg)
{
Form form = arg as Form;
Application.Run(form);
}
[STAThread]
static void Main(string[] args)
{
Form form = new Form() { Text = "test" };
Thread t = new Thread(ThreadProc);
t.Start(form);
string line = Console.ReadLine();
Console.WriteLine(line);
form.Close();
}
}