I want to make the program wait for a button to be pressed before it continues, I tried creating a while loop and having it loop until the button is clicked and sets a bool
If you need the program to wait for that event then don't write the waitForTheButton code in your main access/Page load.
Instead write your code inside the event. So you don't have to make an active wait. Events are for that.
eg: If you have something like this
static void Main()
{
while (notPressed) { }
DoThis();
DoThat();
}
Then you could be changing it to:
static void Main
{
myButton.OnClick += myButton_EventHandler;
}
private void myButton_EventHandler(object sender, EventArgs e)
{
DoThis();
DoThat();
}
If you really want to work in a procedural paradigm even when you are using a OOP language, you should use a Semaphore or something like that. But that doesn't seem to be what you actually need, It's more like something you want.