|
-
November 20th, 2008, 09:05 PM
#1
waiting for the process to die
invoking winword process from the main thread , then wanna continue when the process has been closed (died)
I not sure if i m setting all the parameters correctly or not.
do u see anything obvious why while WINORD is still live it detects it not to be running?
Cheers
Code:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
bProcessDone = 0;
proc.StartInfo.FileName = "winword";
proc.StartInfo.Arguments = pfile;
proc.EnableRaisingEvents = false;
proc.Start();
Thread.Sleep(2000);
bool bFound = false;
for(;;)
{
Process[] allProcs = Process.GetProcesses();
foreach (Process thisProc in allProcs)
{
if (proc.Id == thisProc.Id)
{
bFound=true;
}
}
if (bFound)
{
bFound = false;
continue;
}
else
{
break;
}
}
// shoudl not be here if the process is still running but it is
-
November 20th, 2008, 10:05 PM
#2
Re: waiting for the process to die
you may just use Wait*****it() <-- that is W a i t F o r E x i t ( )
Code:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
bProcessDone = 0;
proc.StartInfo.FileName = "winword";
proc.StartInfo.Arguments = pfile;
proc.EnableRaisingEvents = false;
proc.Start();
proc.Wait*****it();
proc.Close();
proc.Dispose();
Last edited by Thread1; November 20th, 2008 at 10:07 PM.
Reason: huh!?
Busy 
-
November 20th, 2008, 11:16 PM
#3
Re: waiting for the process to die
Thanks for the advice but I have laready tried that and it does not seem to work for me for some that i m determined to find out before i go home tonight or i wont be able to sleep 
Code:
proc.StartInfo.FileName = "winword";
proc.StartInfo.Arguments = pfile;
proc.EnableRaisingEvents = false;
proc.Start();
Thread.Sleep(2000);
proc.Wait*****it();
proc.Close();
proc.Dispose();
// should not get here when winword is running but it is
System.IO.FileInfo Info2 = new System.IO.FileInfo(pfile);
-
November 21st, 2008, 02:10 AM
#4
Re: waiting for the process to die
Try
Code:
proc.Start();
proc.WaitForInputIdle( );
proc.WaitF orE xit( );
-
November 23rd, 2008, 10:06 PM
#5
Re: waiting for the process to die
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|