开发者

Am I supposed to dispose redirected StandardOutput/StandardError

开发者 https://www.devze.com 2023-03-11 08:01 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号