如何在taskmanager中运行或不运行应用程序 [英] how to I get application is running or not in taskmanager

查看:539
本文介绍了如何在taskmanager中运行或不运行应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有示例都显示获取进程名称。但是我想通过c#检查应用程序(taskmanager->应用程序选项卡)是否正在运行。



diagnostics.process返回进程名称,而不是应用程序名称。

解决方案

您可以尝试 GetProcessesByName [ ^ ] - 如果我读得正确,只需将您的应用程序名称传递给它......但您需要对此进行测试。





试试这个:

  //  启动流程。 
流程proc = Process.Start( your_installer_b.msi);

// 等待流程结束 - 请注意,这将阻止调用应用程序
proc.WaitForExit();

MessageBox.Show( 安装B完成。);







基于事件的等待 [ ^ ]:



< pre lang =c#>进程proc = Process.Start( your_installer_b.msi);
proc.EnableRaisingEvents = True
proc.ProcessExited + = your_handler;















如果这有帮助,请花些时间接受解决方案。谢谢。


  已解决。我正在调用所需的进程 by  mainwindowtitle属性,它显示了我想要的应用程序名称。然后使用等待  退出方法 < span class =code-keyword>然后 执行 一些代码。 
但已退出的事件 甚至触发即使是启动事件 true。您知道任何原因吗?


All examples show to get process name.But I want to check if an application (taskmanager->application tab) is running or not by c#.

diagnostics.process returns process names,not application name.

解决方案

You can try GetProcessesByName[^] - if I read this correctly, simply pass it your application name...but you'll need to test this.


Try this:

// Start the process.
Process proc = Process.Start("your_installer_b.msi"); 

// Wait for the process to end - NOTE THAT THIS WILL BLOCK CALLING APPLICATION
proc.WaitForExit();

MessageBox.Show("Installation B finished.");




Event based wait[^]:

Process proc = Process.Start("your_installer_b.msi"); 
proc.EnableRaisingEvents = True
proc.ProcessExited += your_handler;








If this helps, please take time to accept the solution. Thank you.


It is solved.I am calling required process by mainwindowtitle property,it shows application name which I wanted.Then I use wait for exit method and then execute some code.
But exited event is not firing even enableraisingevent is true.Do you know any reason?


这篇关于如何在taskmanager中运行或不运行应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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