cancel
Showing results for 
Search instead for 
Did you mean: 

How to Exit UI Application when B1 Exit?

Former Member
0 Kudos

I got a problem that when B1 Exit and the UI program still running in the computer and didn't exit. I can find that EXE still run in the task manager and occupy computer resources. Anyone know the reason? How to fix the problem?

Please help

Anna

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Anna.

Try this on item event handler.


...
' global when load the form 
sFormUID = oForm.UniqueID

' ... Handler SBO_Application.ItemEvent 
Dim oForm As SAPbouiCOM.Form
oForm = SBO_Application.Forms.Item(FormUID)
'... other events
' ...exit 
If (FormUID = sFormUID) And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_CLOSE) Then
  Windows.Forms.Application.Exit()
End If

Or see this [How to stop the Add-on running the process|]

Regards

Sierdnas

Edited by: Sierdna S on Jul 15, 2008 11:59 AM

Former Member
0 Kudos

    Private Sub SBO_Application_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles SBO_Application.AppEvent

        '//********************************************************************************
        '// the following are the events sent by the application
        '// (Ignore aet_ServerTermination)
        '// in order to implement your own code upon each of the events
        '// place you code instead of the matching message box statement
        '//********************************************************************************

        Select Case EventType

                Case SAPbouiCOM.BoAppEventTypes.aet_ShutDown Or SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition
                SBO_Company.Disconnect()
                SBO_Company = Nothing
                End_Add_On(0)
                '//**************************************************************
                '//
                '// Take care of terminating your AddOn application
                '//
                '//**************************************************************
                End

            Case SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged
                SBO_Company.Disconnect()
                SBO_Company = Nothing
                End_Add_On(0)
                '//**************************************************************
                '// Check the new company name, if your add on was not meant for
                '// the new company terminate your AddOn
                '//    If SBO_Application.Company.Name Is Not "Company1" then
                '//         Close
                '//    End If
                '//**************************************************************

            Case SAPbouiCOM.BoAppEventTypes.aet_LanguageChanged
                AddMenuItems()
                '//**************************************************************
                '// Check the new language name, if your AddOn's items needs
                '// to be changed, take care of it at this point
                '//
                '//    Select Case SBO_Application.Language
                '//         Case ln_English:
                '//         Case ln_French:
                '//         Case ln_German:
                '//    End Select
                '//**************************************************************

        End Select
    End Sub

 Private Sub End_Add_On(ByVal ExitCode As Integer)
        Dim oMenus As SAPbouiCOM.Menus
        Dim oMenuItem As SAPbouiCOM.MenuItem

        Try
           {Remove all the menu entries created by Add-On}
        Catch
            Exit Try
        End Try
        System.Environment.Exit(ExitCode)
    End Sub

Just copy/paste this code,

Regards,

WB

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear Anna,

You may refer to SAP Note 891115 'Stop a registered AddOn correctly in VB.net' for help this issue.

Best Regards

Jane Jing

SAP Business One Forums team

Former Member
0 Kudos

Dear

You'd better catch both

aet_ServerTemination and aet_ShutDown.

If it does not help, please also try the followings:

If you use

sConnection = Enviroment.GetCommandLineArgs.GetValue(1)

then Change to

sConnection = (THE CONNECTION STRING ITSELF)

Best Regards,

Xiaodan AN