检查过程中的地位 [英] Check status of process

查看:175
本文介绍了检查过程中的地位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望以编程方式验证应用程序的状态,看它是否已经崩溃或停止。我知道如何确定进程是否存在,在C#中,但我也可以看到,如果它是没有响应?

I want to programmatically verify the status of an application to see if it has crashed or stopped. I know how to see if the process exists in C# but can I also see if it is "Not responding"?

推荐答案

您需要的一切都在System.Diagnostics程序,例如:检查进程是否响应

Everything you need is in System.Diagnostics, for example: to check if a process is responding.

using System;
using System.Diagnostics;

namespace ProcessStatus
{
    class Program
    {
        static void Main(string[] args)
        {
            Process[] processes = Process.GetProcesses();

            foreach (Process process in processes)
            {
                Console.WriteLine("Process Name: {0}, Responding: {1}", process.ProcessName, process.Responding);
            }

            Console.Write("press enter");
            Console.ReadLine();
        }
    }
}

这篇关于检查过程中的地位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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