Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Am I supposed to dispose redirected StandardOutput/StandardError

Tags:

.net

process

If I 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).

like image 502
SFun28 Avatar asked Jun 06 '11 22:06

SFun28


1 Answers

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.

like image 92
Teoman Soygul Avatar answered Oct 19 '22 23:10

Teoman Soygul