Create a form in the main thread? [closed]
Can someone please explain how I can create a form in the main thread of my application, using C#?
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MyForm());
}
What I know and based on previous answers here, The form you will create will be by default in the main thread.
You need to look at other answers as well for details and code sample for creating a form.
Form1 form = new Form1();
form.Show();
But I don't think that is what you want as an answer. Maybe detail it a bit more?
Here is the code you can use:
Form form = new Form();
form.Show();
精彩评论