"DraguVaso" <pi**********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I have made some classes, but when they are Finalized/Disposed
or simply "MyClass = Nothing", I want to trigger this action, and
ask to save unsaved changes.
Finalizing/Disposing are definitely not the same as setting a
Variable to Nothing.
If you have code that you want to be called when the object is
"no longer needed", have the class implement IDisposable and
put the code into your Dispose method (have a look at the
Dispose code written into any Windows Forms you create).
It is /convention/ that when discarding an object that /has/ a
Dispose method, the caller /should/ do so (sadly, this isn't
actually /enforced/ anywhere).
Also, with regards this bit ...
"ask to save unsaved changes"
.... spare a thought for /how/ you intend to do this.
The quick answer is to pop up a MessageBox - but this could
leave you a bit stuck further down the line if you want to, say,
reuse these classes in a Windows Service; these don't like
MessageBox's very much at all.
HTH,
Phill W.