473,387 Members | 1,897 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Timeout on an async file read

I'm doing an asynchronous 'read' operation on a file, and I want to abort
the operation if it hasn't completed within a certain time (it's a DVD I'm
reading from, and occasionally the sectors are bad). Under Win32 I can do
this by specifying a timeout using the OVERLAPPED structure etc, but in
System.IO.File there's nothing provided to allow this. One solution that
seems to work is to set off the asynchronous read using BeginRead, and also
start a timer that fires after say 500mS ; if the timer fires first (before
the read operation completes) I kick down to the Win32 API and issue a
CancelIo on the file handle. This *seems* to work - but is it perfectly safe
and kosher ? Or a nasty hack that will bite me in the future ?

Steve (in paranoid mood)
Nov 15 '05 #1
0 1230

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jim | last post by:
Hi, I am trying to figure out a way to implement a timeout along with a read() call on an open file. It only has to work on linux, for now I am trying: ret = select.select( ,,, timeout ) if...
1
by: Ahmet AKGUN | last post by:
Hi All; I have one server to which clients are connected to via TcpChannel. I start server on one host and establish a client connection from another host via tcpchannel. On client, using...
1
by: Mark Smith | last post by:
Hi , Is it possible in .Net to define a async timer callback. What I am wanting to do is declare a time-out condition that gets executed should the something timeout. The reason I want to do...
3
by: Helge Jensen | last post by:
I am implementing a protocol which transmits messages. The messages are most naturally transferred using the a Stream so the protocol can communicate over serial-ports, network links, .... If...
0
by: Alan Z. Scharf | last post by:
1. I have a set of six async calls to SQLServer2000 SP's. 2. These six SP's run fine in SQLServer Query Analyzer when called from a master SP executing the individual SP's in succession. 3....
1
by: Sagaert Johan | last post by:
Hi I tried to get around the problem on an un-available remoting server bij using the async methods (BeginInvoke) but noticed that this call is blocking if the remote server is not available....
5
by: Bob | last post by:
This question has been brought up before but I have yet to find a reasonable answer. Can someone explain to me how to create a timeout for the BeginSend method? I have seen where people say to...
2
by: archana | last post by:
Hi all, I am processing asynchronous web request with setting timeout using RegisterWaitForSingleObject. On beginwebrequest i am sending address of one callback which i want to execute when...
0
by: iwr | last post by:
Hello, I'm moving parts of some windows socket-based code to boost.asio. My async socket is connected to a server, and I noticed, that when the server goes down in a "non-graceful" way (eg.,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.