can anybody help me in calculating the completion of a
system.diagnostics.process.start
Process runprocess = new Process();like for example I have this code :-
runprocess.StartInfo.FileName = "cmd.exe";//download the nmap application first to run nmap ..
runprocess.StartInfo.Arguments = "/c nmap -T4 -A -v -oX - 192.168.1.1-10 > file.xml";
runprocess.StartInfo.UseShellExecute = false;
runprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;// hiding the console
runprocess.StartInfo.CreateNoWindow = true;
runprocess.Start();now I want to calculate process progress ..
while(!runprocess.HasExited)
{
//code to calculate the completion of the process and saving it to a int variable ..
}please help me out with this I have searched everywhere but didn't get anything..
VulpesPosted Apr 5, 2013, 6:12 AM
Remember that the operating system has no idea (and no way of telling) how long a process takes to run and the Process class therefore has no data on this.
GIFTED VishPosted Apr 5, 2013, 5:57 AM
VulpesPosted Apr 5, 2013, 5:51 AM
1. Estimate how long the process takes on average to run.
2. Start a StopWatch object when the process starts so that on each iteration of the while loop you can get the current elapsed time and hence deduce the estimated percentage completed to date. If this exceeds 100%, record 99% say.
3. Stop the StopWatch when the process finally exits.