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 查看销售订单时,报了一个错误 ...
随机推荐
- 原创:CentOS6.4配置solr 4.7.2+IK分词器
本文原创,转载请注明出处 相关资源下载:http://pan.baidu.com/s/1pJPpiqv 1.首先说明一下 solr是java语言开发的企业级应用服务器,所以你首先安装好jdk,配置好j ...
- Intel Visual Fortran Compiler 11调用lapack库实现并行多处理计算
采用fortran进行数值计算的朋友们都应该听说过大名鼎鼎的lapack库,我就不多做介绍了,在此,我只是介绍一个编译好的lapack二进制包ACML(AMD Core Math Library),并 ...
- 【转】全面解析Unity3D自动生成的脚本工程文件
http://blog.csdn.net/jjiss318/article/details/7632041 我们在Unity3D开发的时候,经常会看到它会产生不少固定命名工程文件,诸如: Assemb ...
- APP 上架苹果应用商城
http://www.360doc.com/content/15/0203/15/19663521_445974056.shtml http://jingyan.baidu.com/article/4 ...
- Bootstrap 标签页和工具提示插件
一.标签页 标签页也就是通常所说的选项卡功能. //基本用法 <ul class="nav nav-tabs"> <li class="active&q ...
- nrf51822-广播模式
解决以下几个问题: 1 SDK9 中的几种广播模型 2 广播超时如何进入睡眠 3 如何取消广播超时睡眠使其可以无限广播. 1 SDK9 中的几种广播模型 Nordci SDK对于广播方面有一个模块.这 ...
- duplicate symbol _OBJC_CLASS 错误处理方法
错误: ld: duplicate symbol _OBJC_CLASS_$_************ in **************** 一种可能性是你的项目的不同group里有着相同名称的类 ...
- 获取枚举Description 属性
/// <summary> /// 获取枚举变量值的 Description 属性 /// </summary> /// <param name="obj&qu ...
- the differences between function and procedure
一.自定义函数: 1. 可以返回表变量 2. 限制颇多,包括 不能使用output参数: 不能用临时表: 函数内部的操作不能影响到外部环境: 不能通过select返回结果集: 不能update,del ...
- 面向对象世界里转转七(Liskov替换原则)
前言:Liskov替换原则是关于继承机制的应用原则,是实现开放封闭原则的具体规范,违反了Liskov原则必然意味着违反了开放封闭原则.因此,有必要对面向对象的继承机制及其基本原则做以探索,来进一步了解 ...