Re: Does Process.WaitForExit() Really Wait?
- From: "Jonathan Wood" <jwood@xxxxxxxxxxxxxxxx>
- Date: Thu, 28 May 2009 21:36:58 -0600
"Peter Duniho" <NpOeStPeAdM@xxxxxxxxxxxxxxxx> wrote in message news:op.uun0cdar8jd0ej@xxxxxxxxxxxxxxxxxxxx
Well, I'm running another process on that file, as you know, so that would be the process in question. [...]
Is this a process you have the code for? Are you sure it's closing the file properly?
Originally, it was the AVG command line anti-virus software. But after a while, I wrote my own program. My program is a simple C++ program (not Windows) that simply opens the file for read and write access, builds a checksum of every byte in the file, and then closes the file. My program checks for every possible error at every stage. I'm able to see that my program reports no errors were encountered.
Whether I run the AVG utiltity or my own program, the file cannot be deleted afterwards in about 1 out of 5 cases.
Note that AVG has some low-priority options that may or may not spawn additional threads or processes. That's why I wanted to rule that out, even though the return value from the AVG software appeared valid.
If it's not, then it's possible that you are managing to race with the OS, as it has to clean up the open file handle for the process that just exited (it obviously can't do that before the process exits). But assuming you know the file is being closed properly by the process, then by the time you see the process exit, I just don't see how the file could still be open.
That makes two of us--I'm really at a loss. I supposed there is a possibility that it takes a moment to REALLY close a file and my program is returning before Windows can clean everything up. But that's a guess at best.
I suppose stranger things have happened though. All that said, it's barely a .NET problem, never mind a C#-specific thing. You may get more informed responses in a different forum.
Well, I'm new to using Process this way. This is the object that tells me when the program is done. I may be able to get more help elsewhere but I just don't have enough information to know where or to post meaningful information to anyone not using Process.
Thanks.
Jonathan
.
- Follow-Ups:
- Re: Does Process.WaitForExit() Really Wait?
- From: Peter Duniho
- Re: Does Process.WaitForExit() Really Wait?
- References:
- Does Process.WaitForExit() Really Wait?
- From: Jonathan Wood
- Re: Does Process.WaitForExit() Really Wait?
- From: Peter Duniho
- Re: Does Process.WaitForExit() Really Wait?
- From: Jonathan Wood
- Re: Does Process.WaitForExit() Really Wait?
- From: Peter Duniho
- Re: Does Process.WaitForExit() Really Wait?
- From: Jonathan Wood
- Re: Does Process.WaitForExit() Really Wait?
- From: Peter Duniho
- Does Process.WaitForExit() Really Wait?
- Prev by Date: Re: Calling VB.net modules
- Next by Date: Re: Does Process.WaitForExit() Really Wait?
- Previous by thread: Re: Does Process.WaitForExit() Really Wait?
- Next by thread: Re: Does Process.WaitForExit() Really Wait?
- Index(es):
Relevant Pages
|