Am I supposed to dispose redirected StandardOutput/StandardError
If I开发者_如何学C redirect StandardOutput
/StandardError
when creating a Process
object, should I dispose the StreamReaders
when I no longer need the Process
object? Using reflector I see that Process.Dispose()
does not do this for me (unless I'm missing something).
Yes the process object disposes of its own readers and their underlying streams. Redirected output retrieves a reader instance but the underlying stream is still managed by the processinfo which gets disposed automatically so no, you don't need to dispose of the reader.
精彩评论