How to dispose the shared variable in vb.net
i am using shared object of Asterisk.NET Manager Variable, i assigned it in form load
and i dispose it in main form closing, My problem is after closing the application, application.exe keeps live in task manager, if i not initializing the shared object in form load there is no problem,
My code in form open
Public Shared WithEvents objManager As Asterisk.NET.Manager.ManagerConnection
Public Shared Sub ConnectAsterisk()
Try
objManager = New Asterisk.NET.Manager.ManagerConnection(ELASTIX_IP_ADDRESS, ASTERISK_PORT, ASTERISK_USER_NAME, ASTERISK_PASSWORD)
objManager.Login()
Catch ex As Exception
End Try
End Sub
Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
AsteriskManager.objManager = Nothing
End Sub
can any one please help to do that
Thanks,
Senthil
I think the problem is not in the disposing of the ManagerConnection.
Asterisk.NET Manager doesn’t implement IDisposable.
You have to Logoff.
for vb.net would be
and then destroy the reference: