58 lines
1.4 KiB
C#
58 lines
1.4 KiB
C#
// See https://aka.ms/new-console-template for more information
|
|
|
|
using System.Diagnostics;
|
|
|
|
string separator = "--------------------------------------";
|
|
Console.WriteLine(separator);
|
|
Console.WriteLine("Console Test Application");
|
|
Console.WriteLine(separator);
|
|
Console.WriteLine();
|
|
|
|
Console.WriteLine("calling ext app with args[]:");
|
|
string appPath = "./Utils/ExImp.exe";
|
|
string procArg = @"C:\Temp\test.log";
|
|
Console.WriteLine($"{appPath} {procArg}");
|
|
Console.WriteLine();
|
|
Console.WriteLine("press enter to proceed...");
|
|
|
|
Console.ReadLine();
|
|
|
|
ProcessStartInfo psi = new ProcessStartInfo
|
|
{
|
|
FileName = appPath,
|
|
Arguments = $"{procArg}",
|
|
WindowStyle = ProcessWindowStyle.Minimized,
|
|
//WindowStyle = ProcessWindowStyle.Hidden,
|
|
UseShellExecute = false,
|
|
//CreateNoWindow = true,
|
|
RedirectStandardOutput = true,
|
|
RedirectStandardInput = true,
|
|
};
|
|
|
|
Stopwatch sw = new Stopwatch();
|
|
sw.Start();
|
|
|
|
Process p = Process.Start(psi);
|
|
|
|
string q = "";
|
|
while (!p.HasExited)
|
|
{
|
|
q += p.StandardOutput.ReadToEnd();
|
|
}
|
|
|
|
sw.Stop();
|
|
var timeElaps = sw.Elapsed;
|
|
Console.WriteLine($"Ext prog executed in {timeElaps.TotalMilliseconds} ms");
|
|
Console.WriteLine(separator);
|
|
Console.WriteLine("press enter to proceed...");
|
|
|
|
Console.ReadLine();
|
|
sw.Restart();
|
|
Console.WriteLine("Data received:");
|
|
Console.WriteLine(q);
|
|
Console.WriteLine();
|
|
sw.Stop();
|
|
timeElaps = sw.Elapsed;
|
|
Console.WriteLine($"Display executed in {timeElaps.TotalMilliseconds} ms");
|
|
|
|
Console.ReadLine(); |