madogumglynium
madogumglynium
CC#
Created by madogumglynium on 7/5/2023 in #help
✅ Capturing process output
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.outputdatareceived?view=net-7.0#examples I am using the following example to try and capture a process output and print it to a textbox at runtime. The process output is captured, but it is only printed after the process has terminated. how do I make sure to print at runtime?
var path = "C:\\program.exe";
Process process = new Process();
process.StartInfo.FileName = path;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
{
if (!String.IsNullOrEmpty(e.Data))
{
output.Append(e.Data + "\r\n");
}
});
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
tboxConsole.AppendText(output.ToString());
process.WaitForExit();
process.Close();
var path = "C:\\program.exe";
Process process = new Process();
process.StartInfo.FileName = path;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
{
if (!String.IsNullOrEmpty(e.Data))
{
output.Append(e.Data + "\r\n");
}
});
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
tboxConsole.AppendText(output.ToString());
process.WaitForExit();
process.Close();
72 replies
CC#
Created by madogumglynium on 7/5/2023 in #help
❔ Capturing process output
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.outputdatareceived?view=net-7.0#examples I am using the following example to try and capture a process output and print it to a textbox at runtime. The process output is captured, but it is only printed after the process has terminated. how do I make sure to print at runtime?
var path = "C:\\program.exe";
Process process = new Process();
process.StartInfo.FileName = path;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
{
if (!String.IsNullOrEmpty(e.Data))
{
output.Append(e.Data + "\r\n");
}
});
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
tboxConsole.AppendText(output.ToString());
process.WaitForExit();
process.Close();
var path = "C:\\program.exe";
Process process = new Process();
process.StartInfo.FileName = path;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.OutputDataReceived += new DataReceivedEventHandler((sender, e) =>
{
if (!String.IsNullOrEmpty(e.Data))
{
output.Append(e.Data + "\r\n");
}
});
process.Start();
process.BeginOutputReadLine();
process.WaitForExit();
tboxConsole.AppendText(output.ToString());
process.WaitForExit();
process.Close();
3 replies
CC#
Created by madogumglynium on 7/2/2023 in #help
❔ hosting an asp.net core api in a winform app.
How can I host an asp.net core api in a winform app, where the api starts and stops based on user gui input and where the api console is displayed on the gui?
78 replies