Re: Using Interface to dispose and null and object

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



yes correct
after I make the calls to dispose the CurrentModule and set to null the ProductsModule is still not null and I can browse its properties etc.

What other code would you like?

Thanks for your help.

Dan



"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message news:MPG.21c67dae73a475386ce@xxxxxxxxxxxxxxxxxxxxxxx
Daniel Jeffrey <daniel_c_jeffrey@xxxxxxxxxxx> wrote:
I may be on the wrong track here but I thought I could do this, but it isn't
working.

I have a class which I have used a interface to define.

This class is then inherited from, and many of them are used (conditionally)
on a form.

In order to simplify my dispose area, I thought I could use the interface to
dispose and null the items, but it doesn't seem to work.

It will work fine, but you haven't posted enough code for us to work
out what the probem is. Are ProductsModule and StatusModule definitely
non-null?

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

.



Relevant Pages

  • Re: Using Interface to dispose and null and object
    ... after I make the calls to dispose the CurrentModule and set to null the ... ProductsModule is still not null and I can browse its properties etc. ... World class .NET training in the UK: http://iterativetraining.co.uk ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: to dispose or not ?
    ... If someone calls a custom method Dispose and even bether is filling the ... As said before by me and others the Idisposable interface is a contract, ... Dim intCount As Integer ... Dim entry As New DirectoryServices.DirectoryEntry ...
    (microsoft.public.dotnet.languages.vb)
  • Re: How can I call base interface method?
    ... it means you can only inherit one implementation. ... By definition, it is an interface, not an implementation. ... Hence, in your derived class, you can have the Dispose() method. ... public virtual void Dispose() ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: to dispose or not ?
    ... Dispose is not unlike any other property or method in that regard. ... Well i guess you both forget that the idisposable interface only has one ... As said before by me and others the Idisposable interface is a contract ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Memory Leak Experts!!!!
    ... dispose would get rid of the object but the reference would still exist. ... interface implementation has interfered with the normal function of the GC. ... Deterministic disposing or implementing the IDispose pattern is only a ... >I think that you are confusing Dispose with Finalise. ...
    (microsoft.public.dotnet.framework.performance)