I'm trying to change Forms using threads. Initially I used Hide()
and Show()
to hide the previous Form from the next one, the problem is that when I close the application there is always something running in the backgorund. My idea is this: From Form1 clicking a button goes to Form2 which in turn can choose whether to return to Form1 or go to Form3 which in turn can choose whether to return to Form2 or Form1
This is a piece of code from the Form1 button that if clicked must take me to Form2. The point is that it does not close Form1 and in fact it always remains in the background and when I click the button to close Form2 (using Close ()
) the program does not close and remains at Form1 and if I close that then the program closes definitively
The second form is called OptionGeneral
Thread StartThread = null;
public void btnOptions_Click(object sender, EventArgs e)
{
StartThread = new Thread(SwitchForm);
StartThread.Start();
//Hide();
OptionGeneral option = new OptionGeneral();
option.Show();
}
public void SwitchForm()
{
StartThread.Abort();
}