Modal Form not closign cleanly

N

nick_nw

Hi All,

I think I'm missing a basic bit of understanding with modal forms.
This is the problem I have:

1. User clicks button on form, event handler throws an exception.
2. In catch block a form is shown modally (i.e. errForm.ShowDialog
()).
3. When the user closes the dialog the form image stays on the screen
and the app stops painting.

I'm using C# with .Net 1.1. This isn't repeatable and try as I might I
can't get this to reproduce in a small sample app (which suggests a
problem with my 'big' app). What I'd like, is a detailed discussion of
modal forms. Does anyone have such a resource?

Many thanks,
Nick Gardner
http://seecharp.blogspot.com/
 
G

Guest

I dont think its the modal nature of the form that will be causing you an
issue but what you do after the form has been closed. Could you post a code
sample of the catch block at least?

Ciaran O'Donnell
 
J

justin creasy

Try placing an Application.DoEvents(); after the .ShowDialog() line.
Also, is this a multi-threaded application where maybe the threads are
not background threads? Just some thoughts.
 
N

nick_nw

justin said:
Try placing an Application.DoEvents(); after the .ShowDialog() line.
Also, is this a multi-threaded application where maybe the threads are
not background threads? Just some thoughts.

Hi, thanks for the replies.

The catch bloc looks like this:

catch (Exception ex)
{
errForm = new errForm ();
errForm.Exception = ex;
errForm.ShowDialog ();
}

I've tried calling Application.DoEvents () to no avail.
I've tried all possible combinations of control.Invoke and BeginInvoke
(even though I've proven that all operations are on the main GUI
thread).
There is something else happening that can't be solved in a short code
sample. I do not say this lightly but I suspect a bug in the .Net 1.1
framework. Unfortunately I can not produce a small test program that
reproduces the bahaviour (I know how this sounds, must be my app right?
Look, I'm not ruling anything out).
What I want is to develop an in depth understanding of modal forms.
What would be the best resource (short of Rotor, CLR specs, and other
such dry sources)?

Many thanks,

Nick
 

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