B4J Question Shell and Wait for

Firpas

Active Member
Licensed User
Longtime User
Hello everyone

In a B4J UI application i have this method to start a webserver (B4J non UI Application)

B4X:
Private Sub ServerStart
    Dim Sh As Shell
    Sh.Initialize("ServerStart", "Java.exe", Array As String("-jar", File.Combine(File.DirApp, FM.AppSvr & ".jar")))
    'Sh.Initialize("ServerStart", "Java.exe", Array As String("-jar", FM.AppSvr & ".jar"))
    Sh.Run(-1)
    Wait For ServerStart_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    Log("Success=" & Success)
    Log("ExitCode="& ExitCode)
    Log("StdOut=" & StdOut)
    Log("StdErr=" & StdErr)
'    If Success And ExitCode = 0 Then
'        Log("Srevidor iniciado")
'    Else
'        Log(StdErr)
'    End If
End Sub

but the Wait For sentence is ignored

What is my mistake ??

Thanks in advance
 

MarkusR

Well-Known Member
Licensed User
Longtime User
did you try the example "without wait for usage" i mentioned?
 
Upvote 0

Firpas

Active Member
Licensed User
Longtime User
Yes, here is the code

B4X:
Private Sub ServerStart
    Dim Sh As Shell
    Sh.Initialize("ServerStart", "Java.exe", Array As String("-jar", File.Combine(File.DirApp, FM.AppSvr & ".jar")))
    'Sh.Initialize("ServerStart", "Java.exe", Array As String("-jar", FM.AppSvr & ".jar"))
    Sh.Run(-1)
    
End Sub

Sub ServerStart_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    Log("Success=" & Success)
    Log("ExitCode="& ExitCode)
    Log("StdOut=" & StdOut)
    Log("StdErr=" & StdErr)
'    If Success And ExitCode = 0 Then
'        Log("Srevidor iniciado")
'    Else
'        Log(StdErr)
'    End If
End Sub

and Sub ServerStart_ProcessCompleted is not triggered
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
did u use a class modul / standard class?
i believe in code modul there are no events

what happens with TimeoutMsset >0 at Run(.. ?
 
Upvote 0

Firpas

Active Member
Licensed User
Longtime User
No, it is a estándar class (Main)
I think i know what's the problem
The applications was already running, but …
the parameter "StdErr" must show any information, true?
 
Last edited:
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
If the called method does not return any value, then the wait for does nothing... but wait...
 
Upvote 0

Firpas

Active Member
Licensed User
Longtime User
I had found some bugs in the server application and i had fix it.
Now all run ok.

Thanks to everybody for your cooperation.
 
Upvote 0
Top