Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2008 Feb : Is TFileStream doing synchronous IO?
| Subject: | Is TFileStream doing synchronous IO? |
| Posted by: | "Mark Tiede" (mtie..@mjwcorp.com) |
| Date: | Fri, 15 Feb 2008 11:46:02 |
I have an application with 2 background threads that do IO using
TFileStream. I have having problems that are difficult to pin down because
they aren't reproducable. One suspicion is that, even though I am doing the
filestream IO inside critical sections, perhaps the actual IO is occuring
asynchronously. Doesn't tfilestream do synchronous IO?
Here is brief description of what I am doing. I have 2 scrollable windows
that shows thumbnails. Each window has its own thread where are separate
classes. The thread gets its list of files to display from separate
sources. Once the list has been obtained, the threads execute their main
routine. That routine reads an item from the list of files, loads the
picture from disk as a DIB, resizes the DIB to thumbnail size, writes the
thumbnail out to a file using the TFileStream, posts a message back to the
window that the thumbnail is on disk. The thumbnail keeps track of the
offset into the file to get the bitmap of it is to draw. When the paint
method is called, the thumbnail goes to the proper offset in the file and
reads its bitmap and draws it.
This seems to work quite well most of the time. The scrolling window shows
the thumbnails as they are being loaded. But every now and then, I get a
white thumbnail. I THINK that most of the time this is happening, the
bitmap is actually being written out as white. I don't think the problem is
in reading in a valid one. I had one time when I thought the file was good
and a customer told me the drawn image was white.
So I have 2 main sources of suspicions. One would be that the actual IO is
asynchronous and even though I have critical sections around the filestream
operations, somehow the reading is screwing up the writing. The other
suspicion I have is that the ImageLib routines I am using to get information
about the file and to read the image to a DIB is screwing up. But again, I
think all that activity is protected by critical sections.
So, does anyone know if tfilestream is FOR SURE synchronous (which I think
it is)? And does anyone have any other suggestions?