I am developing windows forms application. I am communicating with serial port using separate thread. On button click I am closing the serial port and aborting the thread using Thread.Abort()
.But I am getting
Thread was being aborted exception.
private void button1_Click(object sender, EventArgs e)
{
Thread1.Abort();
if (isPortOpened)
{
serialPort1.DataReceived -= DataReceivedHandler;
serialPort1.Close();
}
}