george

george

  • NA
  • 23
  • 46.1k

System.StackOverflowException when closing my form

Sep 19 2008 8:55 PM

hi  i close my form and serial port with a button

 

private void button1_Click(object sender, EventArgs e)

{

if (serialPort1.IsOpen) serialPort1.Close();

Close();

}

 

and with the X button in form

private void Form1_FormClosing(object sender, FormClosingEventArgs e)

{

if (serialPort1.IsOpen) serialPort1.Close();

Close();

}

 

but some times have problem and i get System.StackOverflowException

i dont know why?

 

 

 

 


Answers (5)