Is it possible to call Application.Run, but to not pass a form parameter, or is there an alternative if there’s no form to call?
The Run method doesn’t seem to have any overloads that don’t accept a form.
For example, if I wanted to instantiate a class first, and then have that call the form, is there way to do the equivalent of:
Application.Run(myClass);
Just to clarify, I do still want the functionality that .Run() provides. That is, establish a loop to keep the application running, but instead of tracking a form, track a class or other object.
This is relating to the compact framework initially. I assume that’s why the Run method doesn’t have the overload I was looking for.
I’m not clear whether you want to do:
For (1):
What you need to know is your program starts from the first line of the main and ends at the last. However, when you call
Application.Run(FORM)it loads up a windows message loop for that form. Its a special loop that keeps the program still in the main and waits for events (they’re called Windows Messages in win32 API)And so the program does not end until the user clicks the close button. When this happens, thats when your program actually will
returnfrom its Main.(2) So now if you just want a pure console app with no forms:
I hope that helped.