SerialPort.PinChanged Event

Definition

Indicates that a non-data signal event has occurred on the port represented by the SerialPort object.

public event System.IO.Ports.SerialPinChangedEventHandler PinChanged;

Event Type

Remarks

Serial pin changed events can be caused by any of the items in the SerialPinChange enumeration. Because the operating system determines whether to raise this event or not, not all parity errors may be reported. As part of the event, the new value of the pin is set.

The PinChanged event is raised when a SerialPort object enters the BreakState, but not when the port exits the BreakState. This behavior does not apply to other values in the SerialPinChange enumeration.

PinChanged, DataReceived, and ErrorReceived events may be called out of order, and there may be a slight delay between when the underlying stream reports the error and when the event handler is executed. Only one event handler can execute at a time.

The PinChanged event is raised on a secondary thread. Because this event is raised on a secondary thread, and not the main thread, attempting to modify some elements in the main thread, such as UI elements, could raise a threading exception. If it is necessary to modify elements in the main Form or Control, post change requests back using Invoke, which will do the work on the proper thread.

For more information about handling events, see Handling and Raising Events.

Applies to

Produit Versions
.NET 8 (package-provided), 9 (package-provided)
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided)