Process.ErrorDataReceived Event

Occurs when an application writes to its redirected StandardError stream.

Namespace:  System.Diagnostics
Assembly:  System (in System.dll)

[<BrowsableAttribute(true)>]
[<MonitoringDescriptionAttribute("ProcessAssociated")>]
member ErrorDataReceived : IEvent<DataReceivedEventHandler,
    DataReceivedEventArgs>

The ErrorDataReceived event indicates that the associated process has written to its redirected StandardError stream.

The event only occurs during asynchronous read operations on StandardError. To start asynchronous read operations, you must redirect the StandardError stream of a Process, add your event handler to the ErrorDataReceived event, and call BeginErrorReadLine. Thereafter, the ErrorDataReceived event signals each time the process writes a line to the redirected StandardError stream, until the process exits or calls CancelErrorRead.

NoteNote

The application that is processing the asynchronous output should call the WaitForExit method to ensure that the output buffer has been flushed.

The following example uses the net view command to list the available network resources on a remote computer. The user supplies the target computer name as a command-line argument. The user can also supply a file name for error output. The example collects the output of the net command, waits for the process to finish, and then writes the output results to the console. If the user supplies the optional error file, the example writes errors to the file.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

  • LinkDemand 

    for full trust for the immediate caller. This member cannot be used by partially trusted code.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft