How to wait for CD to Mount
How to wait for CD to Mount
How to wait for CD to Mount
How to wait for CD to Mount
How to wait for CD to Mount
How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount
How to wait for CD to Mount How to wait for CD to Mount
How to wait for CD to Mount
Go Back  Xtreme Visual Basic Talk > > > How to wait for CD to Mount


Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2003, 06:48 PM
freak99 freak99 is offline
Newcomer
 
Join Date: Dec 2003
Posts: 3
Default How to wait for CD to Mount


I'm writing a program that calls another program that mounts CD images into a virtual CD. My program then uses the mounted image like a regular CD.

The problem is that the program I run to mount the CD returns from the command line before it is actually done. And in the next few lines of code when I go to read from the mounted image I get a System.IO.IOException saying that the drive is not ready.

How can I check to see if the image is mounted before proceeding to read from it?

I'm hoping there is some nice clean event-oriented way of doing this. I'm still pretty new to VB.Net so a short example would be helpful.
Reply With Quote
  #2  
Old 12-18-2003, 07:10 PM
reboot's Avatar
rebootHow to wait for CD to Mount reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

You could do it with a Try Catch inside a loop, break out of the loop when it doesn't error.

Code:
Dim flag As Boolean = True While flag Try System.IO.File.Open("d:\test.txt", IO.FileMode.Open) flag = False Catch ex As Exception End Try End While
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #3  
Old 12-19-2003, 07:31 AM
freak99 freak99 is offline
Newcomer
 
Join Date: Dec 2003
Posts: 3
Default

Quote:
Originally Posted by reboot

Code:
Dim flag As Boolean = True While flag Try System.IO.File.Open("d:\test.txt", IO.FileMode.Open) flag = False Catch ex As Exception End Try End While



This is kind of what I wanted to avoid Is there a cleaner way to do this with event handlers?
Reply With Quote
  #4  
Old 12-19-2003, 09:27 AM
reboot's Avatar
rebootHow to wait for CD to Mount reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

Code:
Dim p As Process = Process.Start("yourProgram.exe") p.EnableRaisingEvents = True AddHandler p.Exited, AddressOf OnProcessExited

OnProcessExited fires when your cd mount program is done.
Reply With Quote
  #5  
Old 12-19-2003, 05:41 PM
freak99 freak99 is offline
Newcomer
 
Join Date: Dec 2003
Posts: 3
Default

Quote:
Originally Posted by reboot
Code:
Dim p As Process = Process.Start("yourProgram.exe") p.EnableRaisingEvents = True AddHandler p.Exited, AddressOf OnProcessExited

OnProcessExited fires when your cd mount program is done.



Thanks for giving it another try but this won't work because the command line program finishes before the virtual drive is actually set up by windows. I need a way of checking whether the drive can be read so that I can pause for 1sec in a loop or something. Immediately after the program is run the drive is not readable, only after a few seconds it is.
Reply With Quote
  #6  
Old 12-19-2003, 06:09 PM
reboot's Avatar
rebootHow to wait for CD to Mount reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,614
Default

Then I don't see how you can do anything else besides my first suggestion. You might ask over on our sister forum Extreme DotNetForums. They have some really sharp people over there.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
beginner...help please tweak_hp Game Programming 13 06-06-2003 09:21 AM
how could i implement wait newneel General 3 05-02-2003 02:57 PM
Wait Cursor icon for user to wait newneel General 1 04-09-2003 10:00 AM
Shell and wait with batch files rpeare General 3 12-03-2002 03:22 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How to wait for CD to Mount
How to wait for CD to Mount
How to wait for CD to Mount How to wait for CD to Mount
How to wait for CD to Mount
How to wait for CD to Mount
How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount How to wait for CD to Mount
How to wait for CD to Mount
How to wait for CD to Mount
 
How to wait for CD to Mount
How to wait for CD to Mount
 
-->