Hi
My VB.NET project has a Form which wraps a proprietary ActiveX control.
Efffectively the Form acts as a Class becuase the control must be placed on
a Form. The Form is not displayed by the application.
The application instantiates the Form, uses the control to connect to a
backend process disconnects, closes the Form and then performs a garbage
collection. However after four or five cycles of this the control stops
connecting to the backend process. I know the particular control to be
reliable becuase I've used it in VB6 projects without any problem. I
suspect after the Form and control is closed it's not being properly garbage
collected.
At present I've setup the following.
In the Form_Closing event I call the Control's disconnect method and then
the Control.Dispose method.
In the sub that instantiates the Form I've included the following:
If Not (lfrmCTI Is Nothing) Then
lfrmCTI.Close()
lfrmCTI.Dispose()
lfrmCTI = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
End If
Can someone tell me if this is the correct strategy to use to guarantee that
my Form and the control that it hosts will be detsroyed? Thanks.
--
----------------------------------------------------
This mailbox protected from junk email by MailFrontier Desktop
from MailFrontier, Inc. http://info.mailfrontier.com