cancel
Showing results for 
Search instead for 
Did you mean: 

Terminate the Running Application

Former Member
0 Kudos

Hai To All,

Iam running the application its all gets connected. But i had one issue, while application is running inbetween iam ending the process of SAP B1 Application that is i go to task manager and i stop SAP. Now the vb.net application alone is in process. If i end the process of SAP B1, the vb.net application want to stop running..How to do that....

Anyone got idea about this????????/

Regards,

Anitha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI Anitha

yes agree with David. This is the correct solution and it is work. TESTED.

if I understood well: even SAP B1 is stopped from Task Manager (END TASK funtion), your add-on is still running, and the Question is how to stop your addon automatically.

Is XL reporter or any other SAP add-on is still running, They have not build in any feature like this

So solution could be to time by time monitor the SAP B1 Process, and when it's ends, close the addon.

Insert this code into your add-on


    Private Sub StartMonitorSAPB1()
        Dim SAPB1Timer As New System.Timers.Timer
        AddHandler SAPB1Timer.Elapsed, AddressOf MonitorSAPB1
        SAPB1Timer.Interval = (1000 * 10) ' 5 seconds
        SAPB1Timer.Enabled = True
        SAPB1Timer.Start()

    End Sub

    Private Sub MonitorSAPB1(ByVal source As Object, ByVal e As Timers.ElapsedEventArgs)
        Dim MyProcs() As Process = Process.GetProcessesByName("SAP Business One")
        If MyProcs.Length = 1 Then
            'Alive
        Else
            'SAP has been exited do clean up your add-on here....
            End
        End If

    End Sub

now activate the monitoring when at single sign on


...
 StartMonitorSAPB1()

Regards,

J.

Edited by: Janos Nagy on Jul 25, 2008 11:39 AM

Edited by: Janos Nagy on Jul 25, 2008 11:41 AM

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Ani,

I have solved without threading... good solution. Tested, working...

Regards,

J.

former_member209699
Contributor
0 Kudos

Hi,

In your main class code add this in your application event. Might this help.

Private Sub objApplication_AppEvent(ByVal EventType As SAPbouiCOM.BoAppEventTypes) Handles objApplication.AppEvent

If (EventType = SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged Or EventType = SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition Or EventType = SAPbouiCOM.BoAppEventTypes.aet_ShutDown) Then

System.Windows.Forms.Application.Exit()

End If

End Sub

regards:

Sandy

Nussi
Active Contributor
0 Kudos

Hi Sandeep,

i don't expect an "event" when the SBO is hard killed from taskmanager.

your code is good when the sap is closed normaly but not with a process kill !

lg

Former Member
0 Kudos

Thanks for ur code but i wrote this code already.............

Nussi
Active Contributor
0 Kudos

Hi Ani,

quite unusual to kill the SB'O with the taskmanager - but ok

use threading in your addon and run a timer that looks if the connection is still alive.

this will be quite tricky. (i used threading to animate a system tray icon while the addon is working)

lg David

Former Member
0 Kudos

Thanks for ur reply David,

Can u tell me how u r using threading??? Can u tell any samples for that?????///

Regards,

Anitha

Nussi
Active Contributor
0 Kudos

Hi Anitha,

i think Janos idea is good.

but ok - i've a good mood and you are interested in something new

i did it in c#

here are the important things


using System.Threading;

private hread trd;

    public int CreateThread()
    {
        // create thread for animation
        trd = new Thread(new ThreadStart(CallYourProcedure));
        trd.IsBackground = true;
        trd.Start();

        return 1;       
    }

    public int KillThread()
    {
        trd.Abort();
        trd = null;
        GC.Collect();
        GC.WaitForPendingFinalizers();

        return 1;
    }

    public void CallYourProcedure()
    {
          // insert your code here

          Thread.Sleep(500);
    }

well - i hope you're satisfied

lg David