C#中啟動進程的三種辦法
啟動子進程,不等待子進程結束view plaincopy to clipboardPRint?
·········10········20········30······ ····40········50·······60·······70·······80········90 ·······130·······140·······150
private void simpleRun_Click(object sender, System.EventArgs e)
{ System.Diagnostics.Process.Start(@"C:listfiles.bat");
} .Diagnostics.Process.Start(@"C:listfiles.bat");
}
2.啟動子進程,等待子進程結束,並獲得輸出view plaincopy to clipboardprint?
private void runSyncAndGetResults_ClickobetResults .EventArgs e)
{
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:listfiles.. psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden ;
psi.UseShellExecute = false;
System.Diagnostics.Process ); System.IO.StreamReader myOutput = listFiles.StandardOutput;
listFiles.WaitForExit(2000);
if (listFiles.HasExited)
{
this.processResults.Text = output;
}
}
private v. System .Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(@"C:listfiles.bat");
psi.RedirectStandardOutput = true;
seShellExecute = false;
System.Diagnostics.Process listFiles;
listFiles = System.Diagnostics.Process.Start(psi);
System.Out.StreamReaderc. 2000);
if (listFiles.HasExited)
{
string output = myOutput.ReadToEnd();
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)
{ .net;
System.Diagnostics.Process.Start(targetURL);
} )!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

使用 C# 的 Active Directory 指南。在這裡,我們討論 Active Directory 在 C# 中的介紹和工作原理以及語法和範例。

多線程和異步的區別在於,多線程同時執行多個線程,而異步在不阻塞當前線程的情況下執行操作。多線程用於計算密集型任務,而異步用於用戶交互操作。多線程的優勢是提高計算性能,異步的優勢是不阻塞 UI 線程。選擇多線程還是異步取決於任務性質:計算密集型任務使用多線程,與外部資源交互且需要保持 UI 響應的任務使用異步。
