【发布时间】:2018-05-29 10:42:26
【问题描述】:
我想使用 c# 使用多个线程执行应用程序
我尝试了以下正常方法,应用程序执行如何?
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);
}
【问题讨论】:
-
我想为以下场景运行代码 -
5 thread execute 1 application目前我正在执行一个线程运行方法 5 次。 -
所以你的问题与线程无关。您只想知道如何从 .NET 程序执行控制台应用程序?
-
我想在执行 c# 时也使用多线程我试过这样 - 更新的问题,,
标签: c# multithreading thread-safety