Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Data display in text box correctly But the problem is whenever i tried to exit the Form system will give exception.
The I/O operation has been aborted because of either a thread exit or an application request

What I have tried:

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing.
(
Try

If serialport1.open = True Then
serialport1.close()
Me.close()
catch ex As Exception
End try
)

To read data through serial port serialPort.ReadLine is Used.
The data shown in Hyper terminal
21701RC 21701RC 21701RC 21701RC and so on continously.
Posted
Updated 17-Aug-18 9:17am
v3
Comments
CoderzF1 17-Aug-18 15:25pm    
Just so you know, the people of codeproject do not typically help with a person's assignments. Don't expect an exact answer here. Someone may point you in the correct direction, so that you may research how to properly close a serial port connection. In this situation, it depends on how you are continuously reading from the serial port. Are you using multiple threads? Are you using timers?, etc... you probably should update you question with a few more details, so that someone may point you in the right direction.
CHill60 20-Aug-18 8:06am    
Good advice from @clwprogrammer but you should also get rid of the try-catch ... you are swallowing any errors without finding out what they are

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900