a simple design question

Jun 3, 2015
Programming Experience
I have a script that will recursively search a folder and for every model and texture map it finds, another script will be executed to convert this file from one format to another. I'm using the processStartInfo class to launch this other program and passing through parameters from my recursive script. I thought it was working ok, but in testing (many different scenarios), I'm finding that it's now consistently getting hung up.

Is this a bad idea to call other programs through a recursive function? Each time I run my script it executes 2-3 instances of the processStartInfo without actually completing it once, then just hangs and never processes the conversion.
Last edited:
Firstly, to be pedantic, there is no script. C# is not a scripting language so C# code is not script. It's just code.

Secondly, you're actually using the Process class to run your external tool. The ProcessStartInfo simply tells the Process class how to start.

As for your issue, it's hard to diagnose an issue like that without any access to the tools but my guess would be that the other program doesn't like having multiple instances running at the same time. What you could do it add all the items you find to a queue and then have those items picked off the queue and processed one at a time, so only one instance of the tool is ever running at a time. It will take longer but you then avoid things like contention for common resources.
Thanks for your reply. I ended up getting it to work, but through some unintended method. There were a couple issues I had; one being that I called Process.Start() twice (once when I was constructing the new process) and once on a line below it. I didn't catch this earlier and got rid of the duplicate instance. Even with the single instance of the process, something still wasn't converting... I commented out of my code the .CreateNoWindow, .UseShellExecute, .RedirectStandardError, and .RedirectStandardOutput properties and added .WindowStyle property. For some reason showing the window is allowing the other process to run/complete and it works now.
Top Bottom