Why would a Form open then quickly close?

G

Guest

I'm pretty tired from working all day on this program and this one simple
task of showing a certain form when the app initializes is driving me nuts...

It opens very briefly then quickly disappears... I put Console.WriteLines in
the Closing event and the Dispose event and he VisibleChanged events to see
if any of them are called and only the visibility is changed (probable from
when I call Show() ) Just in case I even put this.Visible=true; inside that
event. and still this form just flashes on screen and goes away....

The only time is stays is if instead of calling Show() I do
ShowDialog(this), but I do not want the modal behavior....

It's a standard Window Form, opened by another standard Windows Form-
nothing groundbreaking here. My main form loads right away and spawns some
thread to load data, once all the data is done this new window is supposed to
show up, which is the window that won't stay open.

Can you think of any reason why this is happening?
 
G

Guest

*shoots himself*

I got tunnelvision from staring at code all day.. forgot about ShowDialog
with no paramters... i think it's time to get some sleep
 
N

news.sbcglobal.net

I have seen a similiar behavior when the thread started in the form load
event handler generated a uncaught exception. The thread was trying to open
a file which was not locked.
 
C

Ciaran

2 Things. First. ShowDialog doesnt have to be model. It just means the form
will close when the DialogResult property is set on it.
Second, your form is most likely dissapearing because you reference to it
goes out of scope. If the its a variable in a function, you need to keep a
reference to the form after the function ends or it is closed

Ciaran
 

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