Hi there everyone,
I’m having a problem with setting up a dotNET process in a separate thread from 3ds Max so that I can continue working in Max while the process finishes in the background.
I read Pete Addington’s BackgroundWorker post on his site, but I don’t think I’m using it right in conjunction with dotNET processes.
Here’s the part I’m having trouble with: I want to run a separate exe file that converts texture files, but as soon as I associate a process with it and run a loop for every texture I want, it blocks Max and I can’t use it. Also a CMD appears every time it goes through the texture files and runs the individual processes, which’d be nice to get rid of too.
Here’s the snippet that takes care of the process:
local dNProcess = dotNetObject “System.Diagnostics.Process”
local dNBGWorker = dotNetObject “System.ComponentModel.BackGroundWorker”
dNBGWorker.RunWorkerAsync
(
for i = 1 to filteredSceneTex.count do
(
procArgs = "-memory 256 etc..."
dNProcess.StartInfo.CreateNoWindow = True -- I thought this'd hide the CMD popping up, but it doesn't
dNProcess.StartInfo.FileName = "C:\converter.exe" -- the program to run
dNProcess.StartInfo.Arguments = procArgs -- passing it these arguments
dNProcess.Start() -- starting the process
dNProcess.WaitForExit() -- waits for the process to finish before going on with the loop, which essentially blocks this thread
)
)
Any idea how to make it run as I’d expect? So that the conversion loop runs in a separate thread as converting large texture files can actually take some time.
Thanks a lot in advance!