从任务管理器或系统Stoped中获取.EXE时的通知。 [英] Get Notification when .EXE from task manager or in system Stoped.

查看:103
本文介绍了从任务管理器或系统Stoped中获取.EXE时的通知。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些Windows应用程序.exe在我的域服务器上运行,我有一个问题,如果.exe被弯曲,我怎么能得到.exe已经弯腰的通知。



是否有任何解决方案我可以通过操作系统操作我的代码并通过邮件或任何其他资源获取通知

I have some windows application .exe which are run in my Domain server, i have a problem that if the .exe is stooped how can i get the notification that the .exe has stooped.

is there any solution thru i can manipulate my code with operating system and get notification thru mail or any other resource

推荐答案

如果你开始代码中的某个进程,即使在停止时也可以捕获,但通常情况下,您需要在单独的线程中处理它。即使您想跟踪每个进程需要单独跟踪线程的多个外部进程,这也不是很昂贵,因为大多数情况下这样的线程将处于等待状态,浪费没有CPU时间。



它看起来像这样:

If you started some process in your code, you can capture the even when it is stopped, but, normally, you would need to handle it in a separate thread. This is not very expensive even if you want to track several external processes requiring a separate tracking thread per process, because most of the time such thread would be in the wait state, wasting no CPU time.

It could looks like this:
using System.Diagnostics;

//...

void SomeThreadStartMethod() {
    Process someExternalProcess = Process.Start("...", "..."); // some parameters
    someExternalProcess.WaitForExit();
    // invoke some event or handle it somehow...
}





如果您没有在服务器中启动流程,您仍然可以获取流程列表,按某些条件选择一个并使用引用它来做同样的等待。请参阅:

http ://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs.110%29.aspx [ ^ ]。



-SA


这篇关于从任务管理器或系统Stoped中获取.EXE时的通知。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆