D
Daniel Jeffrey
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.
Eg.
public interface IDataModule : IDisposable
{ ... }
class ProductsDM : Candle.DataModule, IDataModule
{ ... }
class StatusDM : Candle.DataModule, IDataModule
{ ... }
Form Code
_____________
IDataModule CurrentModule;
Load method...
switch (SetupMode)
{
case SetupFormMode.SETUP_PRODUCTS:
{
ProductsModule = new DataModules.ProductsDM(....);
CurrentModule = ProductsModule;
}
break;
case SetupFormMode.SETUP_STATUSES:
{
StatusModule = new DataModules.StatusDM(....);
CurrentModule = StatusModule;
}
break;
}
Unload Method
if (CurrentModule != null)
CurrentModule.Dispose();
CurrentModule = null;
Now if I put a watch on CurrentModule and the Actually objects, the
CurrentModule is null, but the others are fine.
Any help would be great.
Daniel
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.
Eg.
public interface IDataModule : IDisposable
{ ... }
class ProductsDM : Candle.DataModule, IDataModule
{ ... }
class StatusDM : Candle.DataModule, IDataModule
{ ... }
Form Code
_____________
IDataModule CurrentModule;
Load method...
switch (SetupMode)
{
case SetupFormMode.SETUP_PRODUCTS:
{
ProductsModule = new DataModules.ProductsDM(....);
CurrentModule = ProductsModule;
}
break;
case SetupFormMode.SETUP_STATUSES:
{
StatusModule = new DataModules.StatusDM(....);
CurrentModule = StatusModule;
}
break;
}
Unload Method
if (CurrentModule != null)
CurrentModule.Dispose();
CurrentModule = null;
Now if I put a watch on CurrentModule and the Actually objects, the
CurrentModule is null, but the others are fine.
Any help would be great.
Daniel