| View previous topic :: View next topic |
| Author |
Message |
Peter Morris [Droopy eyes Guest
|
Posted: Tue Jun 21, 2005 9:38 pm Post subject: File is in use |
|
|
I have a report which passes parameters to a calculation routine and
receives a set of results. The report executes this routine many times, the
routine takes about 100 milliseconds to run.
For tracking purposes, every time I run the routine I write the parameters
to a text file using a TStringList. My problem is that rarely I get an
exception from the SaveToFile method telling me that the file is in use.
Has anyone else experienced this? If so do you have a solution?
Thanks
--
Pete
====
ECO Modeler, Audio compression components, DIB graphics controls,
FastStrings
http://www.droopyeyes.com
Read or write articles on just about anything
http://www.HowToDoThings.com
My blog
http://blogs.slcdug.org/petermorris/
|
|
| Back to top |
|
 |
Jan Derk Guest
|
Posted: Tue Jun 21, 2005 10:47 pm Post subject: Re: File is in use |
|
|
Peter Morris [Droopy eyes software] wrote:
| Quote: | I have a report which passes parameters to a calculation routine and
receives a set of results. The report executes this routine many times, the
routine takes about 100 milliseconds to run.
For tracking purposes, every time I run the routine I write the parameters
to a text file using a TStringList. My problem is that rarely I get an
exception from the SaveToFile method telling me that the file is in use.
Has anyone else experienced this? If so do you have a solution?
|
I have seen this happening due to anit-virus software locking the file
for a tiny moment, but long enough for your software to fail.
Resolution #1: Burn down the Symantec headquarters.
Resolution #2: Retry accessing the file after a short moment. Generally
the anti-virus S/W unlocks the file when its done.
The file extension has an influence. *.dat file for example get checked,
thus locked, by Norton, but *.weirdextension often isn't. So often
changing the file extension helps. It does not hurt either to not
release the file lock while you need it, preventing any other
application from grabbing it.
Jan Derk
|
|
| Back to top |
|
 |
Erwien Saputra Guest
|
Posted: Wed Jun 22, 2005 4:58 am Post subject: Re: File is in use |
|
|
Peter Morris [Droopy eyes software] wrote:
| Quote: |
Has anyone else experienced this? If so do you have a solution?
|
1. Check for the file before trying to write it. If the file is
locked, generate another file name.
2. Lock the file all the time.
Usually I do not recommend locking the file all the time, but since
your routine gets called alot, probably it is a solution.
Wien.
--
http://blogs.slcdug.org/esaputra
Delphi Setting Manager - http://www.codeline.net
|
|
| Back to top |
|
 |
Kyle A. Miller Guest
|
Posted: Wed Jun 22, 2005 5:28 pm Post subject: Re: File is in use |
|
|
Peter Morris [Droopy eyes software] wrote:
| Quote: | Has anyone else experienced this? If so do you have a solution?
|
Try Raize CodeSite. Great software. Supports .NET too.
http://www.raize.com/DevTools/CodeSite/Default.asp
|
|
| Back to top |
|
 |
Peter Morris [Droopy eyes Guest
|
Posted: Wed Jun 22, 2005 9:58 pm Post subject: Re: File is in use |
|
|
I don't understand how CodeSite will help me :-)
|
|
| Back to top |
|
 |
Sanford Aranoff Guest
|
Posted: Mon Jun 27, 2005 12:50 pm Post subject: Re: File is in use |
|
|
"Peter Morris [Droopy eyes software]" wrote:
| Quote: | I have a report which passes parameters to a calculation routine and
receives a set of results. The report executes this routine many times, the
routine takes about 100 milliseconds to run.
For tracking purposes, every time I run the routine I write the parameters
to a text file using a TStringList. My problem is that rarely I get an
exception from the SaveToFile method telling me that the file is in use.
|
I would write to a database. Much more reliable than a text file.
|
|
| Back to top |
|
 |
|