المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Displaying the output of a console application in a windows form.



C# Programming
05-23-2009, 06:51 PM
Hi, I want to create an interface for a few applications that run with a command line interface (video codecs, to be specific). I've got it sort of working but after I run one application with it, it just stops displaying the output.

Code on the "Run App" Button: (pro_App is the name of my process component)
pro_App.StartInfo.FileName = txt_App.Text;
pro_App.StartInfo.Arguments = txt_Args.Text;
pro_App.Start();
pro_App.BeginOutputReadLine();
but_Run.Enabled = false;
Events:
private void pro_App_OutputDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
if (!String.IsNullOrEmpty(e.Data))
{
rtx_Display.AppendText(Prefix + e.Data); // Append output to rich text box
Prefix = Environment.NewLine;
}
}

private void pro_App_ErrorDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
{
if (!String.IsNullOrEmpty(e.Data))
{
rtx_Display.AppendText(Prefix + "Error: " + e.Data);
Prefix = Environment.NewLine;
}
}

private void pro_App_Exited(object sender, EventArgs e)
{
but_Run.Enabled = true;
rtx_Display.AppendText(Prefix + "