Process/Threading library (by Andrew Graham) in Basic4PPC

mjcoon

Well-Known Member
Licensed User
I came to B4X via V4PPC, which I am still using.

And in particular am trying to make successive calls to do video transcoding using HandbrakeCLI. But have a problem in that after the second call I don't get a notification of the completion of the Process. So I tried using a timer to poll for completion instead, only to find that the IDE (while debugging) or the EXE (if not) have hung up so the polling fails.

Should I be able to make successive "Process.Start" invocations like that?

TIA, Mike.
 

agraham

Expert
Licensed User
Longtime User
I assume you have the Threading library help file. You should check that Process.Start returns True and only if so then call Process.WaitForExit which waits for the invoked program to exit. Alternatively you can do a Timer poll on Process.Running until it returns false. I don't see how the IDE and EXE can be hanging if you are doing one or the other of these.
 

mjcoon

Well-Known Member
Licensed User
For "V4PPC" please read "V4PPC", of course.

I am more certain that my problem is that my second Process.Start() does not return in either IDE or EXE, so my program is unable to respond when the secondary process completes its task and hence perform further invocations.
 

mjcoon

Well-Known Member
Licensed User
Thanks Andrew. Yes I have the Help files for both version 2 and 3. And also for version 4.8 but I don't have B4PPC version 8.0+ to use with that. I am now certain that the second Process.Start() does not return at all, and hence my program hangs and gets no further.
 

mjcoon

Well-Known Member
Licensed User
Confession time: my Win10 system is weird and I have tried several Microsoft support persons to sort it without success. E.g. sound output does not work at software level and windows update is unreachable. And it has days of multiple crashes and then is stable for days at a time. If we could re-install Win10 (keeping my files) we would! But the Process problem is one of those fractal corners...
 

mjcoon

Well-Known Member
Licensed User
You have made me wonder if my problem is due to performing the second Process.Start() within the Process.Exit event from the 1st. I shall try switching that around.
 

mjcoon

Well-Known Member
Licensed User
You have made me wonder if my problem is due to performing the second Process.Start() within the Process.Exit event from the 1st. I shall try switching that around.
While I do not profess to understand the B4PPC process structure, my conjecture seems to be correct. I first used a loop on Process.WaitForExit as a form of polling. (The shelled program typically takes several tens of seconds to run and I didn't want to risk a single long wait within that.) That worked for multiple successive Process.Start.

Then I wondered if I could use a timer (just a single tick!) to separate the Process.Exit event from the following Process.Start invocation. This also works. I offer that experiment in case it sheds any light on what is going on...

Anyway, I have my work-around for now!
 
Top