I have an application that processes file transfers. In some instances, I need to launch some pre/post processing executables that do stuff with the files.
So the order of events (in brief) would be like this:
Basically, I don't care how long the post process executable runs after the transfer has occurred. Therefore, should I anticipate any problems if I launch the process from a thread that is then returned to the pool?
//Post process
Process process = null;
ProcessStartInfo psi = new ProcessStartInfo(executable, args);
psi.UseShellExecute = true;
try
{
process = Process.Start(psi);
//The pre-process simply calls Process.WaitForExit(timeout value)
launched = true;
}
catch (InvalidOperationException) { }
catch (ArgumentException) { }
catch (System.ComponentModel.Win32Exception) { }
catch (System.IO.FileNotFoundException) { }
There is nothing wrong with that at all.
Think about it:
That's very dangerous. If you use up all of your thread pool threads on long-running tasks then other things that need them will stop working. You can even dead-lock your whole application.
The rule is simple:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.