Joke Collection Website - Blessing messages - Vb.net hangs when the serial port is closed.

Vb.net hangs when the serial port is closed.

When the program responds to the received data, my general process of dealing with this problem is:

Private? Sub? MyCOMM_DataReceived(ByVal? Sender? As? Object? ByVal? e? As?

System. IO . ports . serial datareceivedeventargs)? Handle? MyCOMM。 Data reception

What if? IsClosing? then what Quit Sub? If the interface is shutting down the serial port, exit the process.

attempt

IsListenning? =? True' sets the label being read to be judged by the interface operation.

Wait (150)' Wait150ms.

Dim? n? As? Dragon? =? MyCOMM。 Byte reading

Dim? buf(n? -? 1)? As? byte

attempt

MyCOMM。 Read (buf,? 0,? n)

Catch? Former? As? exception

MsgBox ("Error in receiving SMS", "Behave appropriately. Data reception ")

Throw? New? System. Exceptions (such as messages)

finally

IsListenning? =? "False" turns off the tag being read, regardless of whether the data is successfully received.

End? attempt

MyCOMM。 Close ()

MyCOMM。 Open ()

Do what? something

Catch? Former? As? exception

MyCOMM。 Close ()

MyCOMM。 Open ()

End? attempt

End? submarine

Protected? Sub? Wait (ByVal? Milliseconds As? Integer)

Dim? tmpNow? As? Dating? =? at present

What time? Now Subtract (tmpNow). Milliseconds & lt? millisecond

Apply. DoEvents()

End? During ...

End? Sub hopes to help.