Re: File IO and Threading
- From: "Michael D. Ober" <obermd.@.alum.mit.edu.nospam>
- Date: Sat, 07 Oct 2006 21:03:26 GMT
Can we see your code. At least the writes and deletes.
Thanks,
Mike Ober.
"Sean Chambers" <dkode8@xxxxxxxxx> wrote in message
news:1160251158.389568.11720@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
A better way would be to rename the file first, like logfile.log.old.understand
This way if another thread tries to write, it will recreate the file as
the file doesn't exist, then shortly thereafter the logfile.log.old is
deleted.
Would this work?
If not, try putting a 10ms sleep, then 20ms, all the way up until you
find the correct amount of time to sleep for, although I would
recommend against putting the thread to sleep. I don't usually use this
method as it feels kind of clunky to me.
Sean
Jayme Pechan wrote:
I seem to have run into a strange problem. I'm hoping one of you
arethe inner working of the file IO better than I and could explain why I'm
seeing what I am. Basically, I have a log folder where I append to text
files frequently. Every 10 minutes or so, I check to see if the files
putgreater than a certain size and then archive them. After archiving the
files, I use the File.Delete function to delete each of the files. I
anotherthe File.Delete in a lock section to ensure that it completes before
seemsthreat attempts to write to them. The problem I'm seeing is that it
though itlike the File.Delete doesn't delete the files immediately and even
myis supposed to remove it from the directory tree (I think), if another
thread attempts to append to one of these files too soon after leaving
themlock block, the whole program locks up. I thought of putting in a sleep
after the deletions but I wouldn't know how long to set it for.
My solution is to move the files to a sub folder first before deleting
thebut wanted to see if anyone would know why I'm having this problem in
first place.
Thanks
Jayme
.
- References:
- File IO and Threading
- From: Jayme Pechan
- Re: File IO and Threading
- From: Sean Chambers
- File IO and Threading
- Prev by Date: Re: File IO and Threading
- Next by Date: Re: Why convert a VB6 desktop ap to Dot Net?
- Previous by thread: Re: File IO and Threading
- Next by thread: Re: File IO and Threading
- Index(es):
Relevant Pages
|