[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Process.Wait not behaving as expected
[Thread Prev] | [Thread Next]
- Subject: Re: Process.Wait not behaving as expected
- From: Bruce Steers <bsteers4@xxxxxxxxx>
- Date: Thu, 1 Jan 2026 22:15:41 +0000
- To: user@xxxxxxxxxxxxxxxxxxxxxx
On Thu, 1 Jan 2026 at 17:22, Lee <t.lee.davidson@xxxxxxxxx> wrote: > I am shelling out to a command for which I need to catch any error message > and the exit code. > > I can't use Process.Wait without a timeout as it is a server and my > project application would hang forever. However, when I use > .Wait with any value other than 0, the exit code is not correctly set in > Process.Value. > > Am I misunderstanding how Process.Wait should work, or is this unintended > behavior? > > Demo project attached. > > > -- > Lee I think doing it that way maybe $hProc is dead by the time you check it? You can get the value okay in Process_Kill Public Sub Proc_Kill() Debug Last.Value End It's hard to tell what exactly happens here. If i use the following code in your program... Public Sub Button1_Click() $hProc = Shell System.Shell & " " & Application.Path &/ "main.sh" For Read As "Proc" $hProc.Wait(SpinBox1.Value) Debug $hProc.Value End Public Sub Proc_Kill() Debug $hProc.Value End a Wait time of 0 gives this.. FMain.Proc_Kill.16: 3 FMain.Button1_Click.10: 3 Using any other value gives this ... FMain.Button1_Click.10: 0 FMain.Proc_Kill.16: 3 In both cases Proc_Kill reports correctly but if any wait time is given the Click event comes first and $hProc.Value seems to be zero. Respects BruceS
| Process.Wait not behaving as expected | Lee <t.lee.davidson@xxxxxxxxx> |