C# – Dispose Process.Start(url)

cnet

Simple question: I want to open a URL using the Default Browser, so I just do Process.Start(url). However, I noticed that this returns an IDisposable object.

So now I wonder if I have to dispose it? Or, for that matter, if my Application is in any way responsible for this process? The intended functionality is simply "Fire and forget", I do not want to have my application as a parent of the new process and it does not need to interact with it.

I've seen some similar but unrelated questions on SO that seem to say that simply calling Process.Start on a URL is fine, but I do not want to run into some hard to debug memory leaks/resource exhaustion issues caused my me program keeping references to long dead browser processes.

Best Answer

Couldn't you just wrap it in a using clause to ensure the GC does whatever it needs to do with it IF you are required to dispose of it? This would still allow a sort of "fire and forget" but not leave memory/resources in a bad state.

Probably overkill but there is a really good article on CodeProject about the IDisposable interface: http://www.codeproject.com/KB/dotnet/idisposable.aspx