I have written a program to receive data from the serial port. I am doing some calculations using those data and writing results to 4 richTestBoxes real time.I have two buttons to open and close the serial port. Some times when the close button is pressed, the form get stucked.This is the code in the close button.But this is not happening every time.
private void btnClosePort_Click(object sender, EventArgs e)
{
comport.Close(); // comport is the object created in the class serialport
}
I think the reason is that many fuinctions are running while the port is being closed. Is there any method to stop all the current processes in the program and then close the comport????? or any other solution????