Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When should Overridden Finalize event fire

Status
Not open for further replies.

SBendBuckeye

Programmer
May 22, 2002
2,166
US
Hello all,

I would have guessed that an overridden Finalize would be called when the object goes out of scope since at that point it is no loger accessible in code. However, it appears that it is not called until the parent object goes out of scope. I have a class with an overridden Finalize as below:
Code:
Protected Overrides Sub Finalize()
    Try
        'Do some stuff
    Finally
        MyBase.Finalize()
    End Try
End Sub 'Finalize
I have this code in a form's load event:
Code:
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles etc
    With New AutomationInfo(Me, "c:\dummy.txt", True)
        'Do some stuff
    End With
End Sub 'Form1_Load
The Finalize method shown in example 1 above is not called until the form closes. Is this correct behavior? If so, what else can I call because I can't wait until the parent form closes as that could be who knows how long. Thanks in advance for any ideas and/or suggestions!



 
What are you trying to do in the finalize code?



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top