Share via


Close Method

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Closes the port connection, sets the IsOpen property to false, and disposes of the internal Stream object.

Namespace:  System.IO.Ports
Assembly:  Microsoft.SPOT.Hardware.SerialPort (in Microsoft.SPOT.Hardware.SerialPort.dll)

Syntax

'Declaration
Public Overrides Sub Close
public override void Close()
public:
virtual void Close() override
abstract Close : unit -> unit 
override Close : unit -> unit 
public override function Close()

Remarks

Calling this method closes the SerialPort object and clears both the receive and transmit buffers. This method calls the Component.Dispose()()()() method, which invokes the protected SerialPort..::..Dispose(Boolean) method with the disposing parameter set to true.

The best practice for any application is to wait for some amount of time after calling the Close method before attempting to call the Open method, as the port may not be closed instantly.

.NET Framework Security

See Also

Reference

SerialPort Class

System.IO.Ports Namespace