FolderBrowserDialog causes a program END statement to hang

J

JohnR

Wow, this is unbelieveable. I've narrowed it down to a few lines of code.
Create a new project in VB.NET and put 2 buttons on it (a FBD button and an
EXIT button) and enter these lines for the click events:

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnExit.Click
End
End Sub
Private Sub btnDoFBD_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDoFBD.Click
Dim fbd As New FolderBrowserDialog
fbd.ShowDialog()
fbd.Dispose() 'this stmt does not make any difference as to the program
hanging on the "end" stmt
End Sub

Now run the program, click the FBD button to bring up a FolderBrowserDialog
window, click CANCEL on that window and when you return to your main form
hit the EXIT button. If you get the same results I did, your program will
hang and NOT exit.

Can anybody else verify this behaviour? Does anybody have a workaround???
or am I doing something really stupid that I don't realize?

Thanks,
John
 
C

Crouchie1998

John,

I done what you suggested & mine exits fine

Why are you using 'End' & not 'Application.Exit()'?

Crouchie1998
BA (HONS) MCP MCSE
 
H

Herfried K. Wagner [MVP]

Crouchie1998 said:
I done what you suggested & mine exits fine

Why are you using 'End' & not 'Application.Exit()'?

'End' will cause all open files to be closed and will call
'Environment.Exit(0)' afterwards. 'Application.Exit' will shutdown the
application more properly, but it won't close open files, AFAIS.
 
C

Crouchie1998

End stops code execution at that point, whereas, Application.Exit() is the
safe way I agree & finishes the sub etc first.

Crouchie1998
BA (HONS) MCP MCSE
 
J

JohnR

Some add'l information... I tried this on another system and it worked
fine. We both were running the same version of the VB Studio and
development environment (SP1), so this issue becomes much more complicated.
I still have no feel for how common this error is, or what the
differentiating factor is that causes it to appear. So if anybody else can
duplicate this problem and knows why it happens, please let me know. I will
try application.exit and see if that makes a difference.

Thanks.
John
 
J

JohnR

Ok. Problem solved. Are you ready for this??? I rebooted and then it
worked. No, I'm not running Win98, I am running XP. So I guess I was a
little spoiled by it's general reliability that it took me a whole day to do
what I would have done in 5 seconds if I was running Win98. I rebooted....
Oh, boy.

Thanks to those who took the time to try and duplicate this... I wanted to
share my (embarrassing) solution with you as a gentle reminder that
sometimes, even with XP, a little reboot can go a long way...

John
 
C

Crouchie1998

I wouldn't touch XP with a barge pole & I have slated the product off to
Microsoft Development UK/France & USA over the phone. Quite honestly, I
write applications that pick up on XP as an operating system & then quit the
application because of the fact I am wasting my time programming for a
dreadful waste of disc space. I'd rather go back to DOS - lol. Maybe in SP
200 they may have it sorted

Crouchie1998
BA (HONS) MCP MCSE
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top