Disposing Form from Sub Main

B

Brian

Hello,
I have a frm(login dialog box) that I call from a sub main. Problem is, it
seems to not dispose when the user closes it sometimes.
I am using the me.close. Should I follow that statement with a me.dispose
to make sure the application is actually closing?
Brian
 
J

Jack Jackson

Hello,
I have a frm(login dialog box) that I call from a sub main. Problem is, it
seems to not dispose when the user closes it sometimes.
I am using the me.close. Should I follow that statement with a me.dispose
to make sure the application is actually closing?
Brian

How do you create the form? If the form is modal, do something like:

Using frm As logindialog = New logindialog
frm.ShowDialog()
End Using
 
J

James Hahn

What makes you think it is not being disposed? However you are noticing
that it is not being disposed is probably what is preventing it from being
disposed.
 
B

Brian

sometimes when the user will click the ok button... the app writes to a
couple of databases and then closes. And sometimes the image of the
applcaction will stay on the screen and the only way to get it to go away is
forcing another screen or app to draw over top of it.
Thanks,
Brian
 
J

James Hahn

Is it possible that when the image stays around that indicates that there
has been an error in the DB update and something in the error handler is
keeping a reference to the window?
 
M

Mike McIntyre

Hi Brian,

When and how do you find it does not dispose?

Are you instantiating the login and assigning it to a variable before you
show it?

In that case you can set the variable to nothing and the login form will get
disposed e.g.

Dim myLogin as new LoginForm
myLogin.Show
.... wait for login actions to complete
myLogin = Nothing
.... if login was sucessful now show main form
 
B

Brian

I did check that... and there seems to be no problems there. It also
occurrs on the cancel selection, which just does and Me.Unload.
 
B

Brian

Hello Mike,
Sub Main
'I've tried
dim frm as New frmLogin
frm.Show
or
application.run(frmLogin)
or
using frm as new frmLogin
frm.show
end using
end sub

sub main.....
'I've even tried in my sub main to have something like
do until frmlogin.isdisposed
application.exit()
loop
end sub...
 
A

Armin Zingler

Brian said:
Hello Mike,
Sub Main
'I've tried
dim frm as New frmLogin
frm.Show
or
application.run(frmLogin)
or
using frm as new frmLogin
frm.show
end using
end sub

sub main.....
'I've even tried in my sub main to have something like
do until frmlogin.isdisposed
application.exit()
loop
end sub...


I don't understand some things:

If it's a login form, there is probably code running after closing it,
right? You said the image stays on the screen. But this has nothing to
do with dispose. It gets disposed _after_ it has been closed (with
modeless Forms implicitly and explicitly with modal Forms). How long
does it stay on the screen? What happens meanwhile? Does the application
end? If not, what is still running (Ctrl+Break + Threads + Callcstack)?
Put a breakpoint in the dispose method to be sure that it is not disposed.

Just want to get a picture.


Armin
 

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

Similar Threads


Top