Process启动.exe,当.exe内部抛出异常时,总会弹出一个错误提示框,阻止Process进入结束
public class TaskProcess
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern int SetErrorMode(int wMode); public Process process { get; set; } public void Do()
{
try
{
int oldMode = SetErrorMode(); this.process = new Process();
this.process.EnableRaisingEvents = true;
this.process.StartInfo.FileName = @"\\172.21.11.10\File\Platform\ExecuteFile\LSystem.exe";
this.process.StartInfo.Arguments = @"8 \\172.21.11.10\File\Platform\Configuration\AppSettings.config 17 1 0";
this.process.StartInfo.RedirectStandardError = true;
this.process.StartInfo.RedirectStandardInput = true;
this.process.StartInfo.RedirectStandardOutput = true;
this.process.StartInfo.CreateNoWindow = false;
this.process.StartInfo.ErrorDialog = false;
this.process.StartInfo.UseShellExecute = false;
this.process.Start(); SetErrorMode(oldMode); ThreadPool.QueueUserWorkItem(DoWork, process); process.WaitForExit(); Console.WriteLine("ExitCode is " + this.process.ExitCode);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
} public ArrayList Out = ArrayList.Synchronized(new ArrayList()); private void DoWork(object state)
{
Process process = state as Process; if (process != null)
{
try
{
string line = process.StandardOutput.ReadLine(); do
{
Out.Add(line); line = process.StandardOutput.ReadLine();
Console.WriteLine(line);
}
while (line != null); process.StandardInput.WriteLine("exit");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
}
}
}
参考文章:
http://stackoverflow.com/questions/673036/how-to-handle-a-crash-in-a-process-launched-via-system-diagnostics-process
Process启动.exe,当.exe内部抛出异常时,总会弹出一个错误提示框,阻止Process进入结束的更多相关文章
- 用MPLAB IDE编程时,软件总是弹出一个窗口提示: “the extended cpu mode configuration bit is enabled,but the program that was loaded was not built using extended cpu instructions. therefore,your code may not work properly
用MPLAB IDE编程时,软件总是弹出一个窗口提示:"the extended cpu mode configuration bit is enabled,but the program ...
- Java_Swing程序设计_尝试开发一个登陆窗体,包括用户名、密码以及提交按钮和重置按钮,当用户输入用户名my,密码love时,弹出登陆成功提示对话框。
package com.lzw; import java.awt.*;import java.awt.event.*; import javax.swing.*; public class UseCa ...
- 文件夹名为单字符时右击弹出C++错误
原因:操作系统安装有虚拟光驱软件——WinMount,此错误为WinMount的一个Bug 解决方法: 打开Windows注册表,定位此注册表并删除即可 [HKEY_CLASSES_ROOT\Dire ...
- skyline添加wfs服务时,弹出错误“no layers were found”!
1.问题描述: 使用TerraExplorer Pro添加ArcGIS Server 10.2发布的WFS服务图层时,弹出如下错误: 2.错误原因: 发布wfs服务前,图层数据源的空间参考未设置,不能 ...
- 使你的ActiveX控件执行时不弹出安全性提示(转载)
我们编写一个ActiveX控件在IE中运行,一般会弹出一个安全提示,如何避免这种情况?下面是我在参考前人的文章后,总结出“在浏览器中执行时不弹出警告的ActiveX控件”的两种编写方法,予以备忘.注意 ...
- Eric6中编译窗体时,弹出提示:无法启动pyuic5的解决方案
用 Eric6 与 PyQt5 结合,非常方便的实现界面与逻辑分离,满足python的极速GUI编程,不需要在界面上花很多时间. 这是一对GUI开发完美的组合! Eric6中设计窗体时,弹出提示:‘无 ...
- 如何禁用MySql总是定时弹出一个MySQLInstallerConsole.exe的窗口
如何禁用MySql总是定时弹出一个MySQLInstallerConsole.exe的窗口 禁用mysql总是弹出一个安装框的定时任务这一条安装命令,Installing MySQL 5.6.21 u ...
- 联想E440问题:点击鼠标时,弹出“无法连接synaptics定点装置驱动程序”错误
笔记本:Levono E440 问题描述: 在控制面板中,点击鼠标时,弹出“无法连接synaptics定点装置驱动程序”错误,如何解决? 即使在安装联想的驱动后,也没办法解决 解决步骤: 1. ...
- 【SD系列】SAP 查看销售订单时,报了一个错误消息,“项目不符合计划行(程序错误)”
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[SD系列]SAP 查看销售订单时,报了一个错误 ...
随机推荐
- 7.PHP内核探索:Apache模块介绍
Apache概述 Apache是目前世界上使用最为广泛的一种Web Server,它以跨平台.高效和稳定而闻名.按照去年官方统计的数据,Apache服务器的装机量占该市场60%以上的份额.尤其是在 X ...
- Delphi 如何清除动态数组的内存?
SetLength(glb_IndexConfig,); FreeAndNil(glb_IndexConfig);
- 【No.3 Ionic】超级逗表情 App
本人使用Ionic框架开发了一个 超级逗表情 的App 依赖插件 cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plu ...
- 使用SecureCRT连接ubuntu
SecureCRT SSH2连接新装的UBUNTU 14.04 LTS 发现UBUNTU默认没有安装SSH 服务 在UBUNTU上 sudo apt-get install openssh-serve ...
- Android源码剖析之Framework层升级版(窗口、系统启动)
本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 看本篇文章之前,建议先查看: Android源码剖析之Framework层基础版 前面讲了frame ...
- 对于HIVE架构的理解
1.Hive 能做什么,与 MapReduce 相比优势在哪里 关于hive这个工具,hive学习成本低,入手快,对于熟悉sql语法的人来说,操作简单,熟悉. 2.为什么说 Hive 是 Hadoo ...
- eclipse根据.wsdl文件自动生成webservice的调用客户端
1.工具:eclipse3.3或者是带有webservice插件的eclipse 2. 首先用浏览器访问webservice的站点,接着保存打开的页面,后缀为.wsdl. 3.把保存好的文件拷入ecl ...
- Magento Error – The directory is not writable by server.
When trying to use the insert image functionality in Magento if you receive an error saying: “The di ...
- Linux 性能检测 - CentOS 安装 paramon
简介 paramon是一款性能检测工具. 数据发送:cnt 数据接收:svr Continue...
- 在bash shell中使用getfattr查看文件扩展属性
getfattr用法 用于获取文件扩展属性,返回一系列键值对,参考Linux Man Page. 常用OPTIONS -n name, --name=name Dump the value of th ...