如何不用多线程,实现在一个console程序中实例化一个WinForm
我new一个Form,然后Form.Show()就一闪而过,考虑到有个控件不能在多线程的环境中运行,如何解决这个问题?
如果用System.Windows.Forms.Application.Run后面的程序就不执行了。
[STAThread]
public static void Main()
{
System.Windows.Forms.Form form = new System.Windows.Forms.Form();
form.Show();//一闪而过
......
}
另外能否在程序中用反射动态运行一个新的application,显示这个form
效果就像
[STAThread]
public static void Main()
{
System.Windows.Forms.Application.Run(new System.Windows.Forms.Form());
}
但是这个Run的参数是自己动态传入的继承自System.Windows.Forms.Form的窗口