System.IO.Ports.SerialPort.PinChanged Event

Represents the method that will handle the serial pin changed event of a System.IO.Ports.SerialPort object.


public event SerialPinChangedEventHandler PinChanged


Serial pin changed events can be caused by any of the items in the System.IO.Ports.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 SerialPort.PinChanged event is raised when a System.IO.Ports.SerialPort object enters the SerialPort.BreakState, but not when the port exits the SerialPort.BreakState. This behavior does not apply to other values in the System.IO.Ports.SerialPinChange enumeration.

SerialPort.PinChanged, SerialPort.DataReceived, and SerialPort.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 SerialPort.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 System.Windows.Forms.Form or System.Windows.Forms.Control, post change requests back using System.Windows.Forms.Control.Invoke(Delegate), which will do the work on the proper thread.

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


Namespace: System.IO.Ports
Assembly: System (in System.dll)
Assembly Versions:,
Since: .NET 2.0