How to instantiate a Form while the main form is still responsive
I use .Net Framework 4.0 and C#. I want to dynamically instantiate a form in my code while the main form remains responsive. Is creating a new thread and call Application.Run(newForm)
the only way of doing it? It just looks like a bit of a mess for such a simple thing. I thought it should be so common that the framework should have some kind of built-in functi开发者_如何学编程onality for this.
You don't need another thread to create a new form, and don't call Application.Run
a second time. As long as you don't do anything that blocks the UI (and you never should), both forms will run just fine.
MyForm form = new MyForm();
form.Show();
If you call ShowDialog
instead of Show
from your first form, your first form will be blocked.
精彩评论