Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an app that needs to regularly (1 sec) read a file across the network. Occasionally, the network fails me, and the app can't read the file. Problem is, the app hangs for a very long time each time this occurs, meaning it becomes unusable.

It's actually not important if this read fails occasionally. How can I reduce the timeout when I read from the file? The file is read using a Delphi 2006 FileStream. The target hardware is Win XP and 7.

share|improve this question
You have two basic choices: You can read from the file in a thread or you can use overlapped I/O. – David Schwartz May 13 '12 at 23:46
Thanks @David. In this application it would be preferable to timeout after 1 sec (say) and move on and let the application continue with other more important things, hence my wanting to know about reducing the timeout. I gather if I used overlapped I/O I could continue as soon as I had started the read, but do you know if it is possible to get at the internals of Delphi file I/O at that level - or would I do it myself with WinAPI stuff? – rossmcm May 14 '12 at 2:19

You must log in to answer this question.

Browse other questions tagged .