在.NET检测过程中崩溃 [英] Detecting process crash in .NET
问题描述
有没有一种方法来确定我的程序启动一个进程崩溃?
目前,我找到了解决办法是看 Process.Exit code
并检查值:
Is there a way to determine that a process that my program started has crashed?
Currently, the solution I found is to look at Process.ExitCode
and examine the value:
this.STProcess = Process.Start(this.CreateProcessStartInfo());
this.STProcess.WaitForExit();
if (STProcess.ExitCode != 0)
{
//raise error event...
}
我想知道是否有这样做的更优雅而准确的方法是什么?
I wanted to know if there is a more elegant (and accurate) way of doing this?
我想$用C,#P $ PFER答案和使用P / Invoke是罚款为好。
I would prefer answers in C# and using P/Invoke is fine as well.
P.S - 我需要在Windows XP上运行/ Vista / 7的
P.S - I need to work on windows XP/Vista/7
推荐答案
没有。
除非你能以某种方式影响过程(写入错误的事件日志?一个文件)你有没有外部办法知道一个进程崩溃,因为据我所知。
为了你这只是走一个过程。甚至没有的Windows会在任何地方我知道保存这些信息。它不存在了,除非这个过程在某种程度上保持了细节,他们都走了。
Unless you can influence the process in some way (writing errors to the Eventlog? A file) you have no external way to know that a process crashed, as far as I know. For you it's just a process that went away. Not even Windows is going to keep this information anywhere I know. It doesn't exist anymore and unless the process somehow kept the details, they are gone.
这篇关于在.NET检测过程中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!