- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi All,
A colleague is currently writing a fairly large console app. that reads in data from CD and processes it into a GIS format. Depending on user input, the application will ask for the insertion of up to 4 CDs over the execution of the program.
The problem is that it always takes while from when you insert a CD to when it is readable. This is causing problems as the application will ask you to insert a CD. The user will insert the CD then press ENTER to continue. The application will immediately try to read the required file, but if the CD hasn't spun up, you get a "Device not ready" error.
Is there anyway from within CVF that you can check "IsCDMounted" ? Or similar. I did think of just trying to read the necessary file and keep looping around until it is readable, but that feels like a cludge.
I know you could just add a 10 second delay between when the user presses ENTER and when it trys to read the CD, but if the CD was 'mounted' in 3 seconds, that is just a waste, and it feels cludgy as well.
Any ideas.
Cheers
Ian
A colleague is currently writing a fairly large console app. that reads in data from CD and processes it into a GIS format. Depending on user input, the application will ask for the insertion of up to 4 CDs over the execution of the program.
The problem is that it always takes while from when you insert a CD to when it is readable. This is causing problems as the application will ask you to insert a CD. The user will insert the CD then press ENTER to continue. The application will immediately try to read the required file, but if the CD hasn't spun up, you get a "Device not ready" error.
Is there anyway from within CVF that you can check "IsCDMounted" ? Or similar. I did think of just trying to read the necessary file and keep looping around until it is readable, but that feels like a cludge.
I know you could just add a 10 second delay between when the user presses ENTER and when it trys to read the CD, but if the CD was 'mounted' in 3 seconds, that is just a waste, and it feels cludgy as well.
Any ideas.
Cheers
Ian
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sounds more like a driver issue, in general I would expect the read to hang until the disk spun up. Either that or reprompt you to insert the CD. Retrying internally is a reasonable solution in this case.
James
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe FindFirstChangeNotification API could solve the problem. It raises an event when anything in given directory changes. I'm not sure if it's applicable in the case in question but it's simple enough to give it a try:
Maybe WaitForSingleObject should be applied twice (once CD is removed and once it's inserted). I used it when monitoring changes of "ordinary" directories -- I don't know how it would behave for removable drives.
HTH
Jugoslav
WRITE(*,*) "Please insert next CD" hEvent = FindFirstChangeNotification("E:"C, .FALSE., FILE_NOTIFY_CHANGE_SIZE) iSt = WaitForSingleObject(hEvent) iSt = FindCloseChangeNotification(hEvent)
Maybe WaitForSingleObject should be applied twice (once CD is removed and once it's inserted). I used it when monitoring changes of "ordinary" directories -- I don't know how it would behave for removable drives.
HTH
Jugoslav
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page