Shell.Excute problems

I’m trying to check whether thea.exe is running, I thought

while (sh.IsRunning)

Would do the job but it suspends the form totally while Thea runs

I’m feeding Thea a list of jobs to render, once it renders and exits the form updates the current listbox row as “Done” the sends the next
In VB.NET I never encountered this

Dim sh As New Shell sh.Mode = 2 Dim iptPath as string = Main.Savetxt.Text Dim thea As string = " -nosplash -load " + iptPath +"Script.ipt.thea -exit" Dim thea3 As string = "C:\\Program Files\\Thea Render\\thea.exe" sh.Execute(thea3,thea) while (sh.IsRunning) sh.Poll app.SleepCurrentThread(250) // Commenting this line out or not doesn't change anything... wend

Really loving Xojo by the way, this is about the last thing I have to work out other than this my project is working great :slight_smile:
The only grumble is the cursor seems to have a mind of its own when you try and right click and paste :confused:

[quote=128709:@nige cope]I’m trying to check whether thea.exe is running, I thought

while (sh.IsRunning)
Would do the job but it suspends the form totally while Thea runs

[/quote]

I suppose your project is under Windows ?

By “suspend the form” you mean your app is frozen ? This looks like you are using the default shell mode (synchronous = 0). Then isRunning won’t work at all

If this is the case, you want to use an asynchronous shell instead (Timer.Mode = 0).

Yes the app freezes with a busy cursor, and yes its Windows at the moment, I haven’t tried it on Mac yet
Its set as Mode 2, I’ve tried Mode 1 and its just the same

I’ve moved it to another thread which almost work but now get a threading ui exception on
Dim iptPath as string = Main.Savetxt.Text
Details on threading is really vague

Is your code in a thread? If not, it’s your loop that is freezing the app.

[quote=128725:@nige cope]Yes the app freezes with a busy cursor, and yes its Windows at the moment, I haven’t tried it on Mac yet
Its set as Mode 2, I’ve tried Mode 1 and its just the same[/quote]

Mode 1 should not freeze. The freeze and the busy cursor come from your use of while/wend.

You do not need to poll the shell since apparently you do not do anything with DataAvailable. This should work fine :

Dim sh As New Shell sh.Mode = 2 Dim iptPath as string = Main.Savetxt.Text Dim thea As string = " -nosplash -load " + iptPath +"Script.ipt.thea -exit" Dim thea3 As string = "C:\\Program Files\\Thea Render\\thea.exe" sh.Execute(thea3,thea)

If you need DataAvailable or Completed, insert a class, make its super Shell, then drag an instance on the window called sh, so you can attach event handlers to it, and comment out the first line.

I did post I’d just tried on a different thread and it did work but the textbox for iptPath is throwing an UIexception

no idea were the post went lol, I think me and Tim clashed when I tried to edit my post

Thanks I’ll give it a try

edit… oh the post is there now lol

[quote=128742:@nige cope]I did post I’d just tried on a different thread and it did work but the textbox for iptPath is throwing an UIexception

no idea were the post went lol, I think me and Tim clashed when I tried to edit my post

Thanks I’ll give it a try

edit… oh the post is there now lol[/quote]

No need for a thread. Just go Mode 1, it does the same thing, and remove the while/wend.

If you need to know if thea.exe is running you can use the Completed event of sh to know when it has finished running.

sh.IsRunning works well too, but do not use it within a while/wend. If you absolutely need to monitor it continuously, use a 100 ms multiple timer Action event.

Ok thanks
I just need it to wait while thea is running, in my C# version it uses Application.DoEvents() which just seems to get ignored, but going by the documents is more a console command
the xojo app is processing a list of commands, it writes a file (script.ipt.thea) sends it to thea.exe, thea runs this script which can take seconds or hours once thea closes the form sends the next job
In the ideal world I’d be using the socket client which has very little effect on the form but I still have issues with the DLL, but its getting closer and I haven’t had any success with the Xojo version of the client

if your interested this is what it looks like:

OK thanks Marcel I’ve now got it a lot better, I might try a Timer later on but its good enough to do the rest of the form and test

Thanks for the great advice I know have it working without any lag at all, cheers guys!