Skip to Content
author's profile photo Former Member
Former Member

Terminate the Running Application

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2008 at 09:39 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 25, 2008 at 09:25 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • Posted on Jul 25, 2008 at 09:28 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2008 at 09:50 AM

    Hi Ani,

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

    Regards,

    J.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.