Export (0) Print
Expand All

SerialPort.DataReceived Event

Note: This event is new in the .NET Framework version 2.0.

Represents the method that will handle the data received event of a SerialPort object.

Namespace: System.IO.Ports
Assembly: System (in system.dll)

public event SerialDataReceivedEventHandler DataReceived
/** @event */
public void add_DataReceived (SerialDataReceivedEventHandler value)

/** @event */
public void remove_DataReceived (SerialDataReceivedEventHandler value)

JScript supports the use of events, but not the declaration of new ones.

Serial received events can be caused by any of the items in the SerialData enumeration. Because the operating system determines whether to raise this event or not, not all parity errors may be reported.

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 DataReceived event is raised on a secondary thread when data is received from the SerialPort object. 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 Consuming Events.

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft