启动子进程,不等待子进程结束view plaincopy to clipboardprint?
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
private void simplerun_click(object sender, system.eventargs e)
{ system.diagnostics.process.start(@"c:listfiles.bat");
}
private void simplerun_click(object sender, system.eventargs e)
{ system.diagnostics.process.start(@"c:listfiles.bat");
}
2.启动子进程,等待子进程结束,并获得输出view plaincopy to clipboardprint?
private void runsyncandgetresults_click(object sender, system.eventargs e)
{
system.diagnostics.processstartinfo psi = new system.diagnostics.processstartinfo(@"c:\listfiles.bat");
psi.redirectstandardoutput = true;
psi.windowstyle = system.diagnostics.processwindowstyle.hidden;
psi.useshellexecute = false;
system.diagnostics.process listfiles;
listfiles = system.diagnostics.process.start(psi);
system.io.streamreader myoutput = listfiles.standardoutput;
listfiles.waitforexit(2000);
if (listfiles.hasexited)
{
string output = myoutput.readtoend();
this.processresults.text = output;
}
}
private void runsyncandgetresults_click(object sender, system.eventargs e)
{
system.diagnostics.processstartinfo psi = new system.diagnostics.processstartinfo(@"c:\listfiles.bat");
psi.redirectstandardoutput = true;
psi.windowstyle = system.diagnostics.processwindowstyle.hidden;
psi.useshellexecute = false;
system.diagnostics.process listfiles;
listfiles = system.diagnostics.process.start(psi);
system.io.streamreader myoutput = listfiles.standardoutput;
listfiles.waitforexit(2000);
if (listfiles.hasexited)
{
string output = myoutput.readtoend();
this.processresults.text = output;
}
}
3.使用默认的浏览器打开urlview plaincopy to clipboardprint?
·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150
private void launchurl_click(object sender, system.eventargs e)
{
string targeturl = @http://www.duncanmackenzie.net;
system.diagnostics.process.start(targeturl);
}
以上就是C#中启动进程的三种办法的内容,更多相关内容请关注PHP中文网(www.php.cn)!
Android开发指南中文pdf版,学习android的朋友可以参考下。应用程序基础Application Fundamentals 关键类 应用程序组件 激活组件:intent 关闭组件 manifest文件 Intent过滤器 Activity和任务 Affinity(吸引力)和新任务 加载模式 清理堆栈 启动任务 进程和线程 进程 线程 远程过程调用 线程安全方法 组件生命周期 Activity生命周期 调用父类 服务生命周期 广播接收器生命周期 进程与生命周期 用户界面User Interface
0
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号