Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dos commands freeze UI - even when using .NET Shell

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Morne3D
405 Views, 1 Reply

Dos commands freeze UI - even when using .NET Shell

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?

1 REPLY 1
Message 2 of 2
Morne3D
in reply to: Morne3D

"windows.processPostedMessages()" did the trick

Also my progress bar needed float values instead of integer

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report