草庐IT

range_start

全部标签

c# - Process.Start() 启动的应用程序未获取参数

使用C#,我尝试使用Process.Start()将命令行参数传递给新进程:stringpath=@"C:\Demo\Demo.exe";stringarguments="onetwothree";ProcessStartInfostartInfo=newProcessStartInfo{FileName=path,Arguments=arguments};varprocess=Process.Start(startInfo);我的C应用程序Demo.exe只是回显命令行参数:intmain(intargc,char*argv[]){intcount=0;//Displayeachco

c# - Process.Start() 比在控制台中执行慢得多

我在使用Process.Start()执行.exe时遇到性能问题。.NET的执行时间大约是控制台的5倍。什么会导致这个?这是一个测试程序:publicstaticvoidMain(string[]argv){for(inti=0;i结果是这样的:0Elapsedtime4310ms.1Elapsedtime4330ms.2Elapsedtime4280ms....在cmd窗口中运行它几乎立即返回(不到1秒的执行时间)。尝试使用在控制台中对其进行计时>powershellMeasure-Command{cmd/cstart/wait%EXE%%ARGS%}执行时间大约为750毫秒,快了5

c# - 为什么 Enumerable.Range 实现 IDisposable?

只是想知道为什么Enumerable.Range工具IDisposable.我明白为什么IEnumerator确实如此,但是IEnumerable不需要它。(我在玩我的.Memoise()实现时发现了这一点,它有类似的语句if(enumerableisIDisposable)((IDisposable)enumerable).Dispose();出于好奇,我在它的“sourcefinished”方法中放置了一个断点,并由测试触发。) 最佳答案 Enumerable.Range在其方法主体中使用yieldreturn。yieldret

c# - Process.Start() 从命令提示符窗口获取错误

我正在尝试使用参数启动命令提示进程。现在我想获取有关错误的信息(如果存在)。someProcess=System.Diagnostics.Process.Start(cmd,someArgs);最好的问候,洛维吉 最佳答案 其他答案都是正确的。这是您可以使用的一些代码:ProcessStartInfostartInfo=newProcessStartInfo(cmd,args);startInfo.UseShellExecute=false;startInfo.RedirectStandardError=true;Processso

c# - Process.Start() 和 PATH 环境变量

我有以下简单的C#应用程序,它只是尝试启动“jconsole.exe”,它在我的机器上位于C:\Programs\jdk16\bin中。usingSystem;usingSystem.Diagnostics;namespacednet{publicclassdnet{staticvoidMain(string[]args){try{Process.Start("jconsole.exe");Console.WriteLine("Success!");}catch(Exceptione){Console.WriteLine("{0}Exceptioncaught.",e);}}}}如果我

c# - 为什么 Enumerable.Range 比直接 yield 循环更快?

下面的代码正在检查执行相同解决方案的三种不同方法的性能。publicstaticvoidMain(string[]args){//forloop{Stopwatchsw=Stopwatch.StartNew();intaccumulator=0;for(inti=1;iaccumulator+n);sw.Stop();Console.WriteLine("time={0};result={1}",sw.ElapsedMilliseconds,ret);}//self-madeIEnumerable{Stopwatchsw=Stopwatch.StartNew();varret=GetI

c# - Process.Start ("IEXPLORE.EXE") 在启动后立即触发 Exited 事件。为什么?

我在xp中安装IE8时遇到一个奇怪的问题。我试图在c#中使用System.Diagnostics.Process.Start方法启动IE。我需要捕获IE的退出事件并进行一些操作。但我最终遇到了一个相当奇怪的问题,即IE在启动后立即触发exited事件。这是示例代码ProcessobjProcess=Process.Start("IEXPLORE.EXE","http://google.com");if(objProcess!=null){objProcess.EnableRaisingEvents=true;objProcess.Exited+=newEventHandler(myPr

c# - "StandardOut has not been redirected or the process hasn' t started yet”在 C# 中读取控制台命令输出时

感谢@user2526830提供的代码。基于该代码,我在程序中添加了几行,因为我想读取SSH命令的输出。下面是我的代码,它在while行出错StandardOuthasnotbeenredirectedortheprocesshasn'tstartedyet.我想要实现的是,我想将ls的输出读入一个字符串。ProcessStartInfostartinfo=newProcessStartInfo();startinfo.FileName=@"f:\plink.exe";startinfo.Arguments="-sshabc@x.x.x.x-pwabc123";Processproce

c# - Enumerable.Range 中的 A 到 Z 字符列表

我想从Enumerable.Range中创建一个列表。这个代码正确吗?SurnameStartLetterList=newList();Enumerable.Range(65,26).ToList().ForEach(character=>SurnameStartLetterList.Add((char)character));或者是否有更好的方法来制作此类列表? 最佳答案 大概是这样的?varsurnameList=Enumerable.Range('A','Z'-'A'+1).Select(c=>(char)c).ToList(

c# - 有没有办法阻止 Visual Studio 将 Thread started 和 finished 语句打印到输出窗口中?

我有很多Threadstarted:#49Threadfinished:#49在控制台中,当我想打印一些东西进行调试时很难使用控制台。无论如何要从输出窗口中删除这些语句?我的问题真的很像thisone.该解决方案可以删除已退出的语句,但不会删除已开始和已完成的语句编辑它只发生在XamariniOS项目中 最佳答案 虽然不是真正的解决方案,但这是我组织输出窗口的方式:转到Tools>Options>ExtensionsandUpdates并查找名为VSColorOutput的扩展MikeWard。(免责声明:我不是作者,或与他有任何关