Try ShowDialog() .
The problem is that you are not using a message loop. There are two ways to run it. ShowDialog() has one integrated to make it work. An alternative is to use Application.Run() , either after calling Show() , or with the form as a parameter.
ShowDialog() :
mainform.ShowDialog();
Application.Run() without form:
mainform.Show(); Application.Run();
Application.Run() with the form:
Application.Run(mainform);
All these work.
source share