int test_function(int stop) {
while(stop == 0) {
}
}
This code will continue to run until the end of time as there is nothing in the code to cause it to stop. And that means that even pressing the stop button will have no effect because your program is stuck in this infinite loop. You need to use an external flag so that the loop can check if the stop button has been pressed. Something like:
private bool stop = false;
private: System::Void startButton_Click(System::Object^ sender, System::EventArgs^ e) {
stop = false;
test_function();
}
private: System::Void stopButton_Click(System::Object^ sender, System::EventArgs^ e) {
stop = true;
}
void test_function() {
while(stop == false) {
}
}
}
Although in reality this may still not work as the loop will tend to block the GUI, so use with caution.