I'm working on a program that is form based but I have been asked to add some command line support, this works fine apart from the form flashes up and closes down when running from the command line. Is there anyway to hide the form whilst the command line is running? Some code does refer to controls so the gui would need to be accessible but not visible, is this workable?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
There are a few apps that I've run across which have this behavior right from the constructor of the form class. Basically their constructor handles the command line arguments and the calls an Environment.Exit(0) when the process for the command line args has completed successfully. Calling Environment.Exit before the constructor of the form class complete effectively prevents the form from ever showing up.
Having said that, it's error prone, and I would say that it's been to not have the form class as the startup of the app. Use another class instead which can instantiate and show the form as needed, or process the command line arguments instead.
In your Main method you can create the form such as:
then do any command line processing required.
When not in command line mode simply call: