第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用多線程執(zhí)行控制臺應(yīng)用程序 C#

如何使用多線程執(zhí)行控制臺應(yīng)用程序 C#

C#
溫溫醬 2021-07-08 14:56:11
我想使用 c# 使用多個線程執(zhí)行應(yīng)用程序我試過如下正常方法應(yīng)用程序執(zhí)行怎么樣? public static void OneThread()        {            DateTime startTime = DateTime.Now;            Thread t11 = new Thread(() =>            {                for (int i = 0; i <= 5; i++)                {                    var proc = new Process();        proc.StartInfo.FileName = @"C:\Users\consoleapp.exe";        proc.StartInfo.Arguments = "-v -s -a";        proc.Start();        proc.WaitForExit();        var exitCode = proc.ExitCode;        proc.Close();                }            });            t11.Start();            t11.Join();            Console.WriteLine("execution 1 thread 5 times in {0} seconds", (DateTime.Now - startTime).TotalSeconds);        }
查看完整描述

1 回答

?
動漫人物

TA貢獻1815條經(jīng)驗 獲得超10個贊

我不知道我是否正確理解了這個問題。此代碼有執(zhí)行相同方法的 n 個線程


int n = 5;

for (int i = 0; i < n; i++)

{

    Thread t = new Thread(MethodToExecute);

    t.Start();

}



public void MethodToExecute()

{

    Process process = new Process();

    // Configure the process using the StartInfo properties.

    process.StartInfo.FileName = "pathToConsoleApp.exe";

    process.Start();

    process.WaitForExit();// Waits here for the process to exit.

}


查看完整回答
反對 回復(fù) 2021-07-10
  • 1 回答
  • 0 關(guān)注
  • 273 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號