語言

SerialPort.ErrorReceived 活動

定義

表示以物件代表 SerialPort 的埠發生錯誤。

public:
 event System::IO::Ports::SerialErrorReceivedEventHandler ^ ErrorReceived;
public event System.IO.Ports.SerialErrorReceivedEventHandler ErrorReceived;
member this.ErrorReceived : System.IO.Ports.SerialErrorReceivedEventHandler 
Public Custom Event ErrorReceived As SerialErrorReceivedEventHandler 
Public Event ErrorReceived As SerialErrorReceivedEventHandler 

事件類型

備註

錯誤事件可能由列舉中 SerialError 的任何項目引起。 由於作業系統決定是否要引發此事件,因此並非所有奇偶校驗錯誤都會被回報。

PinChanged事件DataReceivedErrorReceived可能會被打亂順序呼叫,且底層串流報告錯誤與執行事件處理器時程式碼能回報之間可能會有輕微延遲。 一次只能執行一個事件處理器。

若串流尾部位元組發生奇偶校驗錯誤,輸入緩衝區會額外新增一個位元組,值為 126。

當物件收到ErrorReceived錯誤時,該SerialPort事件會在次要執行緒中被觸發。 由於此事件是在次要執行緒中被提出,而非主執行緒,嘗試修改主執行緒中的某些元素,如 UI 元素,可能會引發執行緒異常。 如果需要修改主 Form 執行緒中的 Control元素,或 ,則會使用 Invoke,該請求會在適當的執行緒中完成工作。

如需處理事件的詳細資訊,請參閱 處理和引發事件。

適用於