Dos commands freeze UI - even when using .NET Shell

Dos commands freeze UI - even when using .NET Shell

Morne3D
Enthusiast Enthusiast
638 Views
1 Reply
Message 1 of 2

Dos commands freeze UI - even when using .NET Shell

Morne3D
Enthusiast
Enthusiast

Hi all

I have 3 Dos commands
Then I have a loop that runs X amount of times, based on the amount of contend in an array
In the loop I have another 14 Dos commands, with a progress bar updating between EACH dos command.
The Loop ends and I have another 3 Dos commands.

Doscommand freezes the UI untill the script is done. Any progress bars dont update during the freeze
HiddenDosCommand does the same thing. However if I use the switch

 

HiddenDosCommand ("bla bla bla") donotwait:true

..then the commands run nice and fast and the UI doesnt't freeze, BUT I CAN NOT do this, since each Dos command is dependant on the previous Dos command to complete, before it can continue, otherwise I get errors.

For example I can't create a folder with one command...
then copy files into it
then rename it
then copy more files
then delete the folder
...if the "create folder" part wasn't complete. This is a simplification in my explanation, as the actual commands are complex and take between 1 and 4 seconds to complete each

For the same reason ShellLaunch can't work, because each previous command should complete beforew the next one starts.

So I thought the answer was .NET

I have a function:

fn HiddenDotNetCommand Command=
(
	Process = DotNetObject "System.Diagnostics.Process"
	Process.StartInfo.FileName = "cmd.exe"
	Process.StartInfo.Arguments = "/C " + Command
	Process.StartInfo.UseShellExecute = false
	Process.StartInfo.CreateNoWindow = true
	Process.Start()
	Process.WaitForExit()

	--Process.StartInfo.UseShellExecute = false
	--Process.StartInfo.RedirectStandardOutput = false
	--string output = Process.StandardOutput.ReadToEnd()
)

The commented out bits is other things I tried

 

Then I call the Dos command with something like:

HiddenDotNetCommand ("bla bla bla")

Everything works beautifully if the array only has 1 object and the loop runs just once. If however there are 3 or 4 or more objects in the array, and then the loop runs 3 or 4 or more times, I AGAIN get the stuck UI until the script completes. It works fine, except the UI freezes.

Thoughts?

0 Likes
Accepted solutions (1)
639 Views
1 Reply
Reply (1)
Message 2 of 2

Morne3D
Enthusiast
Enthusiast
Accepted solution

"windows.processPostedMessages()" did the trick

Also my progress bar needed float values instead of integer

 

0 Likes