hi ,guys.
i have just made a windows form that run system diagnostics process ( lets say cmd.exe /C dir c:\\*.* /s )
then my main form get stucked til the proc is done.
while i need it to show me outputs from that proc....
if the proc is short it working good but .. if the proc is 150mb( of mem ) ....
now , i know that i need to work with backgournd worker , i just dont know how ,
please help.
here is my code :
command= "/C dir c:\\*.* /s";
//System.Diagnostics.Process.Start("CMD.exe", asquerd);
System.Diagnostics.ProcessStartInfo oInfo3 = new System.Diagnostics.ProcessStartInfo("cmd.exe", command);
oInfo3.UseShellExecute = false;
oInfo3.ErrorDialog = false;
oInfo3.CreateNoWindow = true;
oInfo3.RedirectStandardOutput = true;
try
{
Process p = System.Diagnostics.Process.Start(oInfo3);
System.IO.StreamReader oReader3 = p.StandardOutput;
string sRes3 = oReader3.ReadLine();
while (oReader3 != null)
{
sRes3 = oReader3.ReadLine();
this.textBox1.AppendText(sRes3+"\n");
if (sRes3.Contains("\n"))
{
oReader3 = null;
}
}
oReader3.Close();
oReader3.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}