开发者

Getting a Process to terminate

I have a process object setup like the following:

Process p = new Process();
p.StartInfo.FileName = command;
p.StartInfo.UseShellExecute = true;
p.StartInfo.Arguments = String.Format(
    commandArguments,
    destinationLocation,
    sourceLocation,
    sourceDirName,
    (string.IsNullOrEmpty(revisionNotes.Text)) ? "" : revisionNotes.Text);

(where undefined values are supplied externally to this code and are val开发者_JAVA百科id). The process in question launches and properly executes with p.Start(); but i need to catch it on termination. The console window flashes up briefly and goes away which would seem to indicate that the process is done, but none of the relevant events are fired (OutputDataRecieved, Exited, etc) and it's like the process never ends. (I'm trying to execute a lua script with some parameters if that's relevant). Can someone help me get this process to stop correctly?


WaitForExit


Have you set the EnableRaisingEvents property of the process to True? You won't catch the Exited event without it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜