public static void KillProcess(string strProcessesByName)//关闭线程
{
foreach (Process p in Process.GetProcesses())//GetProcessesByName(strProcessesByName))
{
if (p.ProcessName.ToUpper().Contains("你要关闭的进程名字"))
{
try
{
p.Kill();
p.WaitForExit(); // possibly with a timeout
}
catch (Win32Exception e)
{
MessageBox.Show(e.Message.ToString()); // process was terminating or can't be terminated - deal with it
}
catch (InvalidOperationException e)
{
MessageBox.Show(e.Message.ToString()); // process has already exited - might be able to let this one go
}
}
}
}

或者这样关闭自己

 Environment.Exit();

最新文章

  1. Android:View随手指移动
  2. (转)Linux进程间通信
  3. win7安装 Apache2.2 PHP5.3 MySQL5.6
  4. 乐在其中设计模式(C#) - 备忘录模式(Memento Pattern)
  5. [转]Introduction to Core Bluetooth: Building a Heart Rate Monitor
  6. .net项目架构改造之搭建基于java环境配置一览【上】
  7. Django REST Framework API Guide 05
  8. 用vue+element-ui开发后台笔记
  9. Linux C++ IDEs
  10. Codeforces Round #486 (Div. 3) D. Points and Powers of Two
  11. linux服务器时间同步失败解决方法
  12. [git] commit 相关的操作
  13. mac下python2.7升级到3.6
  14. webstorm快捷键汇总
  15. wpf datagrid 隔行变色
  16. Windows获取线程起始地址
  17. 单例Singleton模式的两种实现方法
  18. Android性能优化来龙去脉总结
  19. hihoCoder[Offer收割]编程练习赛1题目解析
  20. Spcomm 属性详解

热门文章

  1. 百度Cafe原理--Android自动化测试学习历程
  2. Docker commit 制作weblogic镜像
  3. nginx反向代理架构与安装配置(一)
  4. efcore 级联删除
  5. HTML5/CSS3基础
  6. 633. Sum of Square Numbers
  7. 36 The Benefits of Marriage 结婚的益处
  8. json、JSONObject、JSONArray的应用
  9. 优秀前端工程师必备: 非常常用的checkbox的骚操作---全选和单选demo
  10. 10.N个整数中查找是否相加为K[深度搜索]