Link to home
Start Free TrialLog in
Avatar of deleyd
deleydFlag for United States of America

asked on

Does this test method introduce an undisposed of disposable thing?

Does this test method introduce an object that goes undisposed?
[/[TestMethod]
public void TestMethod1()
{
    DoSomething(new DisposableThing(...))
    ...
}

Open in new window

where DisposableThing is some class that implements IDisposable.

Is this a problem? Should disposable things never be created as parameters, because we don't hold on to them?
Avatar of it_saige
it_saige
Flag of United States of America image

As long as the reference to an object is available to the execution of your program (in scope), then it will not be disposed (if it implements IDisposable) or otherwise garbage collected.

-saige-
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial