on 07-25-2008 10:00 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ani,
I have solved without threading... good solution. Tested, working...
Regards,
J.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.