如何在 exe 进程挂起时收到警报
我有一个exe文件。我们称之为 X.exe 它是我使用 C# 创建的控制台应用程序。 但是,它突然挂起,我必须手动重新启动它。我不想对代码进行任何更改。 我知道我们可以使用 Windows sysinternals 中的 ProcDump 或 Process 监视器。 我可以使用它们来监视我的 x.exe 并在进程挂起时收到电子邮件警报吗? 如果是这样,我应该发送什么具体命令? 如果不是,我还应该用什么来解决这个问题?
编辑/添加:我应该创建一个Windows服务,使用.net的process.GetProcessByName函数识别进程并检查它是否仍在运行?
I have an exe file. Lets call it X.exe It is a console application that I created using C#.
However, it hangs abruptly and I have to manually start it over again. I do not want to make any changes to the code.
I know we can use ProcDump or Process monitors from windows sysinternals.
Can I use them to monitor my x.exe ang get alerted on email when the process hangs?
If so, what specific command should I send over?
If not, what else should I use to solve this problem?
Edit/Add on: Should I use create a windows service, identify the process using .net's process.GetProcessByName function and check if its still running?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下方法处理该问题:
AppDomain.UnhandledException 事件,通过订阅它并在方法内
通过这种方式,您的应用程序将收到一个中心点,该中心点将接收代码未处理的异常,并可以集中的方式处理它们。
请记住,例如
StackOverflowException
无法处理。祝你好运。
You can handle that with, for example :
AppDomain.UnhandledException event, by subscribing to it and inside the method
In this way you have one central point where your application will receive the exception not handled by your code and can process them in centralized way.
Just remember that, for example
StackOverflowException
can not be handled.Good luck.