As part of my holiday weekend, I created an intray application aimed at tracking the build status in a continuous build environment. To complete the aesthetics of the app, I wanted my initial form to be hidden immediately upon startup. A quick Google of the problem found the following MSDN page.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtsksettingformtobeinvisibleatitsinception.asp
What concerned me is that it mentions that, without using Application.Run, there is the possibility that certain functionality wouldn't work. I never liked wondering what *might* go wrong with my code (I have too much problem with what *does* go wrong). With a little bit of experimentation, I found that the following variation gives me the desired result.
public static Main(string[] args)
{
YourForm form = new YourForm();
Application.Run();
}
Additionally, when you are exiting the form, it is important to remember that the message pump initiated by Application.Run needs to be shut down. As a result, you need to include the statement
Application.Exit();
as part of the form shutdown process.