Jaro
Jaro

Reputation: 1754

dispose serial port

I am using using class System.IO.Ports. In some cases this component still runs even when the program is closed. As a result I can not open the new serial port with the same port name, cause it is already opened.

Please, is there any way how to dispose System.IO.Ports in c#?

Upvotes: 1

Views: 974

Answers (2)

n8wrl
n8wrl

Reputation: 19765

When you say "this component still runs..." are you using some 3rd party tool to communicate with the Serial port? Because if you're using System.IO.Ports.Serial, and you properly dispose of it (uinsg a 'using' block) it whould be closed, certainly after your program ends.

Upvotes: 3

SLaks
SLaks

Reputation: 888087

You're looking for the cunningly-named Dispose method.

Upvotes: 2

Related Questions