I have a Windows Form app in C# and am trying to figure out where I would implement the CLI app equivalent of the primary while loop in main(). I am using Visual C#'s gui designer.
EDIT: Problem solved with an instance of Timer.
I have a Windows Form app in C# and am trying to figure out where I would implement the CLI app equivalent of the primary while loop in main(). I am using Visual C#'s gui designer.
EDIT: Problem solved with an instance of Timer.
It's inside the Application.Run
method. You shouldn't call GetMessage
API function directly:
// MyForm is derived from `System.Windows.Forms.Form` class
Application.Run(new MyForm());
It's entered from Application.Run(Form)
. You don't enter any logic in that loop. If you need to respond to input, add event handlers to the particular events to the controls on your form. If you need to run logic periodically, use one of the Timer
classes.
The primary outcome of logic in the message pump in C++ is excess/unnecessary usage of the battery on laptops. You should definitely start rethinking the actual code requirements for meeting your target goal, and they shouldn't include constantly running logic in a spin loop.