H
Helge
I just figured out that the ShowDialog method does not display a form
modally if it is executed from a "busy" ('application not responding'-type )
form. Would be great if anybody confirmed this behaviour.
I put a short example here: Add a button to a form and a click event handler
with the following code:
private void button1_Click(object sender, System.EventArgs e) {
ModalFrm lFrm; // Just an empty form.
System.Threading.Thread.Sleep(10000); // Simulate heavy processing.
// Application.DoEvents();
lFrm = new ModalFrm();
lFrm.ShowDialog(this);
}
After starting the application and clicking on the button, the thread falls
to sleep. While the thread is sleeping keep clicking somewhere on the form,
so that it will display "(application not responding)" after a while. Stop
clicking. When the thread awakes again, it shows the other form. BUT: Notice
that the second form is not modal! The MainFrm is not blocked.
Afer experimenting a lot, I put an Application.DoEvents() after the
Thread.Sleep and suddenly the second form was modal again.
I am not sure if this is a wanted behaviour. This is all tested against .Net
Framework 1.1 and Windows Server 2003.
Helge
modally if it is executed from a "busy" ('application not responding'-type )
form. Would be great if anybody confirmed this behaviour.
I put a short example here: Add a button to a form and a click event handler
with the following code:
private void button1_Click(object sender, System.EventArgs e) {
ModalFrm lFrm; // Just an empty form.
System.Threading.Thread.Sleep(10000); // Simulate heavy processing.
// Application.DoEvents();
lFrm = new ModalFrm();
lFrm.ShowDialog(this);
}
After starting the application and clicking on the button, the thread falls
to sleep. While the thread is sleeping keep clicking somewhere on the form,
so that it will display "(application not responding)" after a while. Stop
clicking. When the thread awakes again, it shows the other form. BUT: Notice
that the second form is not modal! The MainFrm is not blocked.
Afer experimenting a lot, I put an Application.DoEvents() after the
Thread.Sleep and suddenly the second form was modal again.
I am not sure if this is a wanted behaviour. This is all tested against .Net
Framework 1.1 and Windows Server 2003.
Helge