SerialPort.PinChanged 事件

定義

表示在 SerialPort 物件所代表的連接埠上已發生非資料訊號事件。Indicates that a non-data signal event has occurred on the port represented by the SerialPort object.

public:
 event System::IO::Ports::SerialPinChangedEventHandler ^ PinChanged;
public event System.IO.Ports.SerialPinChangedEventHandler PinChanged;
member this.PinChanged : System.IO.Ports.SerialPinChangedEventHandler 
Public Custom Event PinChanged As SerialPinChangedEventHandler 
Public Event PinChanged As SerialPinChangedEventHandler 

事件類型

SerialPinChangedEventHandler

備註

序列 pin 變更事件可能是列舉中的任何專案所造成 SerialPinChangeSerial 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. 作為事件的一部分,會設定 pin 的新值。As part of the event, the new value of the pin is set.

PinChangedSerialPort 物件進入時 BreakState ,而不是在埠結束時,就會引發事件 BreakStateThe PinChanged event is raised when a SerialPort object enters the BreakState, but not when the port exits the BreakState. 此行為不會套用至列舉中的其他值 SerialPinChangeThis behavior does not apply to other values in the SerialPinChange enumeration.

PinChangedDataReceivedErrorReceived 事件可能會依序呼叫,且當基礎資料流程報告錯誤和執行事件處理常式時,可能會有些微延遲。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.

PinChanged事件是在次要執行緒上引發。The PinChanged event is raised on a secondary thread. 因為這個事件是在次要執行緒上引發,而不是在主執行緒上引發,所以嘗試修改主執行緒中的某些元素(例如 UI 元素)可能會引發執行緒例外狀況。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. 如果需要修改 main 或中的元素 Form Control ,請使用 post 變更要求 Invoke ,這會在適當的執行緒上執行工作。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.

適用於