AnsweredAssumed Answered

cancel exit SW

Question asked by Chris Champions on Feb 15, 2016
Latest reply on Feb 16, 2016 by Chris Champions

In the code below, I give the option not to exit the SW but it doesn't seem to work. Soon I hit "YES", SW is shutdown

Any help, please

Thank you

 

Function DisconnectFromSW() As Boolean Implements SolidWorks.Interop.swpublished.SwAddin.DisconnectFromSW
        Dim msg = "Transfer Lincense ?"
        Dim response = MsgBox(msg, MsgBoxStyle.YesNo, "Tranfer Lincese")
        If response = MsgBoxResult.Yes Then
            MsgBox("don't want to exit SW")
            DisconnectFromSW = False
            Exit Function
        Else
            RemoveCommandMgr()
            RemovePMP()
            DetachEventHandlers()


            System.Runtime.InteropServices.Marshal.ReleaseComObject(iCmdMgr)
            iCmdMgr = Nothing
            System.Runtime.InteropServices.Marshal.ReleaseComObject(iSwApp)
            iSwApp = Nothing
            'The addin _must_ call GC.Collect() here in order to retrieve all managed code pointers 
            GC.Collect()
            GC.WaitForPendingFinalizers()


            GC.Collect()
            GC.WaitForPendingFinalizers()


            DisconnectFromSW = True
        End If
    End Function

Outcomes