One last thought. perhaps something to try, or remove, just to see if it has an impact.<br><br>I cannot tell from your original post.<br><br>Are you Creating a file, and then immediately using fileexists to verify that it was made.<br>
or are you creating all the files, and then looping fileexists against a known list of filenames you expect?<br><br>I wonder if you should remove the fileexists check from the thread, based on the fact that <br>if you didn&#39;t raise an error then the files will exist. perhaps the speed of the checks<br>
is creating some kind of file attribute conflict.� Only suggesting it as a way of elimintaing a possible weirdness<br><br>I&#39;ve certainly had a number of occasions in windows where filestreams that I&#39;ve opened and closed <br>
cannot be deleted from explorer because it thinks I&#39;ve still got the file locked.. I put it down to an<br>internal windows or vcl issue.<br><br><div class="gmail_quote">On Fri, Apr 13, 2012 at 3:06 AM, Kyley Harris <span dir="ltr">&lt;<a href="mailto:Kyley@harrissoftware.com">Kyley@harrissoftware.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I know this might be a stupid question.. but what filenaming convention are you using?<br><br>its not a random name based on Time or something where file names are accidentally reused?<br>
im sure its not, but have to ask. <br><div class="HOEnZb"><div class="h5">
<br><div class="gmail_quote">On Fri, Apr 13, 2012 at 12:14 AM, David Moorhouse <span dir="ltr">&lt;<a href="mailto:delphi@moorhouse.net.nz" target="_blank">delphi@moorhouse.net.nz</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Peter<br>
<br>
JC and I are working with JB on this project and it has us all stumped.<br>
<br>
Only one thread writes these files. �Standard threaded app, with one<br>
thread creating the files, and then signalling another thread when it<br>
has finished to consume the files.<br>
<br>
As JB says, the writer thread creates each file, then uses FileExists to<br>
check it is on disk. �This all works ok.<br>
<br>
However when the consuming thread does a FileFirst/FileNext scan some of<br>
the files do NOT exist on the disk.<br>
<br>
Single threading the app is not an option unfortunately :(<br>
<br>
We are nervous about the sleep - hence the call to the list. �Any other<br>
help appreciated.<br>
<br>
Cheers<br>
<span><font color="#888888"><br>
<br>
D<br>
</font></span><div><div><br>
On 12/04/12 16:07, Peter Ingham wrote:<br>
&gt; Just wondering of the key word in the problem description is ... &quot;Thread&quot;.<br>
&gt;<br>
&gt; Do you have multiple threads writing these files?<br>
&gt;<br>
&gt; Are you sure your code is multi-thread safe?<br>
&gt;<br>
&gt; Are you sure the VCL routines you are using are multi-thread safe (a<br>
&gt; number are not)!!<br>
&gt;<br>
&gt; If you force the app to have only one thread, does the problem go away?<br>
&gt;<br>
&gt; If you force parts of the operation to run in the context of the main<br>
&gt; thread (synchronize), does the problem go away?<br>
&gt;<br>
&gt;<br>
&gt; Experience shows that short sleeps often change the conditions of a<br>
&gt; threading bug. �I get especially nervous working with multi-threaded<br>
&gt; code when I find sleeps that are there to &quot;Fix&quot; bugs.<br>
&gt;<br>
&gt; Cheers<br>
&gt;<br>
&gt; On 12/04/2012 2:59 p.m., Steve Peacocke wrote:<br>
&gt;&gt; Hi John,<br>
&gt;&gt;<br>
&gt;&gt; All I can say is that I came across this before and resolved it in much<br>
&gt;&gt; the same way. I looked up the issue at the time and there was some<br>
&gt;&gt; convoluted explanation but in the end I just put it down to the<br>
&gt;&gt; programmer (me) being so fast that even a computer couldn&#39;t keep up. I<br>
&gt;&gt; could live with that explanation.<br>
&gt;&gt;<br>
&gt;&gt; This was about 10 years ago.<br>
&gt;&gt;<br>
&gt;&gt; Steve<br>
&gt;&gt;<br>
&gt;&gt; On Thursday, 12 April 2012, John Bird wrote:<br>
&gt;&gt;<br>
&gt;&gt; � � �I came across an oddity in a program that creates lots (eg 30,000+)<br>
&gt;&gt; � � �files exporting selected data from a database.<br>
&gt;&gt; � � �Some files disappear on slower PCs �even though they are created.<br>
&gt;&gt;<br>
&gt;&gt; � � � �* Files are created in a thread using TFilestream, in a loop<br>
&gt;&gt; � � � �* Each file is being checked that it gets created using a if<br>
&gt;&gt; � � � � �FileExists(filename) in the loop and they always seem to be there.<br>
&gt;&gt; � � � �* Files are written at the rate of around 20-30 per second and are<br>
&gt;&gt; � � � � �mostly around 3KB in size.<br>
&gt;&gt; � � � �* At the end of the big loop a list of files created is created by<br>
&gt;&gt; � � � � �the usual FindNext code.<br>
&gt;&gt; � � � �* On some slower PC�s (XP or Server 2003) some files are missing.<br>
&gt;&gt; � � � � �Faster PC�s with Win7 have all the files. �All PC�s are VMs.<br>
&gt;&gt; � � � �* Files missing might range from 10 to 500, never the same number<br>
&gt;&gt; � � � �* The problem can be cured by putting a 2 millisecond sleep<br>
&gt;&gt; � � � � �between creating each file. �1 Millisecond is not enough.<br>
&gt;&gt;<br>
&gt;&gt; � � �Can anyone shed any light on why this might be the underlying issue<br>
&gt;&gt; � � �and why a sleep might fix it?<br>
&gt;&gt; � � �John Bird<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt;<br>
&gt;&gt; Steve Peacocke<br>
&gt;&gt; Mobile: 0220 612-611<br>
&gt;&gt; Linkedin Professional Profile<br>
&gt;&gt; &lt;<a href="http://nz.linkedin.com/pub/steve-peacocke/1/a06/489" target="_blank">http://nz.linkedin.com/pub/steve-peacocke/1/a06/489</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; NZ Borland Developers Group - Delphi mailing list<br>
&gt;&gt; Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>
&gt;&gt; Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
&gt;&gt; Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; NZ Borland Developers Group - Delphi mailing list<br>
&gt; Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>
&gt; Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
&gt; Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br>
<br>
<br>
_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a href="mailto:delphi@listserver.123.net.nz" target="_blank">delphi@listserver.123.net.nz</a><br>
Admin: <a href="http://delphi.org.nz/mailman/listinfo/delphi" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a href="mailto:delphi-request@listserver.123.net.nz" target="_blank">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe<br>
</div></div></blockquote></div><br><br clear="all"><br></div></div><span class="HOEnZb"><font color="#888888">-- <br>Kyley Harris<br>Harris Software<br><a href="tel:%2B64-21-671-821" value="+6421671821" target="_blank">+64-21-671-821</a><br>

</font></span></blockquote></div><br><br clear="all"><br>-- <br>Kyley Harris<br>Harris Software<br>+64-21-671-821<br>