c# - Process WaitForExit not blocking -
i using filesystemwatcher class convert audio listenable format come in. worked while, until right around time upgraded 4.5 on server. now, work, need debug , set breakpoint method not exit before process runs.
it takes few milliseconds sox convert audio. setting thread.sleep(10000) doesnt fix issue. downgrading project .net 2.0 did nothing.
what's frustrating, process.waitforexit() seemingly not block. while debugging, step right on , wait until file shows in folder.
as always, appreciate assistance.
attached relevant code:
void filecreated(object sender, filesystemeventargs e) { string newname = string.format(@"{0}{1}.mp3", _mp3folderpath, e.name.replace(".wav", "")); string soxargs = @"-t wav -r 8k -c 1"; processstartinfo p = new processstartinfo { filename = _soxpath, arguments = string.format("{0} {1} {2}", soxargs, e.fullpath, newname), createnowindow = true, useshellexecute = false, redirectstandarderror = false, redirectstandardinput = false, redirectstandardoutput = false }; using (process process = process.start(p)) { process.waitforexit(); thread.sleep(10000); //process.close(); } }
Comments
Post a Comment