G
Guest
Hi all,
I am building a VB.Net app on Framework 1.1 using VS.Net 2003. I have a
special logging *singleton* class that needs to do work once every object in
my application has either finalized or been disposed of.
The way I have been doing it is by
1) removing my logging class from the GC's finalizer list on creation:
Public Sub New()
GC.SuppressFinalize(Me)
End Sub
2) handling the AppDomain.CurrentDomain.ProcessExit event in my logging
class :
Private Sub AtProcessExitEventHandler(ByVal sender As Object, ByVal e As
EventArgs)
GC.Collect()
GC.WaitForPendingFinalizers()
System.Threading.Thread.Sleep(1000)
Call AnalyseResults()
End Sub
My problem is that none of my (non-IDisposable) application object
finalizers ever trigger before my logging class has finished doing its work.
The call order goes like this: (validated using breakpoints)
A) My Main method finishes up (all my dispose methods have been called at
that point)
B) The ProcessExit events triggers
C) AtProcessExitEventHandler is executed completely (GC.Collect,
WaitForPendingFinalizers, Thread Sleep and AnalyseResults)
D) THEN, the finalize methods of all finalizable objects are called. (???)
I need D) to come before C). How can I force the Finalizers to be called in
that context?
Tough one heh?
Thanks,
-Etienne Thouin
..Net Technical Lead
AlphaCode R&D
I am building a VB.Net app on Framework 1.1 using VS.Net 2003. I have a
special logging *singleton* class that needs to do work once every object in
my application has either finalized or been disposed of.
The way I have been doing it is by
1) removing my logging class from the GC's finalizer list on creation:
Public Sub New()
GC.SuppressFinalize(Me)
End Sub
2) handling the AppDomain.CurrentDomain.ProcessExit event in my logging
class :
Private Sub AtProcessExitEventHandler(ByVal sender As Object, ByVal e As
EventArgs)
GC.Collect()
GC.WaitForPendingFinalizers()
System.Threading.Thread.Sleep(1000)
Call AnalyseResults()
End Sub
My problem is that none of my (non-IDisposable) application object
finalizers ever trigger before my logging class has finished doing its work.
The call order goes like this: (validated using breakpoints)
A) My Main method finishes up (all my dispose methods have been called at
that point)
B) The ProcessExit events triggers
C) AtProcessExitEventHandler is executed completely (GC.Collect,
WaitForPendingFinalizers, Thread Sleep and AnalyseResults)
D) THEN, the finalize methods of all finalizable objects are called. (???)
I need D) to come before C). How can I force the Finalizers to be called in
that context?
Tough one heh?
Thanks,
-Etienne Thouin
..Net Technical Lead
AlphaCode R&D