Suspend events during operation

P

Pino

Hi to all.

I have a Windows Forms application. In some cases, some operations of form
loading are very long, especially because the forms have a BackgroundImage.

During these operations, the system continues "to answer"... in fact all the
user interactions are registered and applied when the form back to idle
state. I would like to ignore all the system events during these operations.
Can I suspend all the user interactions when the application doesn't
respond?

Example: when I click a form, another form is opened. But if I click two
times before the second form is opened, the second click is "registered" and
a third form is opened. I would like to ignore the second click until the
second form is available.

Any suggestion?

Thanks,

Pino.
 
M

MarkR

It seems like a bad idea to deliberately make your application stop
responding to events. Perhaps you can selectively disable the ones you're
concerned with, though.

For instance, if you have a Button.Click handler that opens a new form,
maybe the first step inside its Click handler should be to disable the
button. This is just like many e-commerce sites, which tell you to click the
"Submit" button only once, and disable the button to help.

e.g. in c#

Button_Click(object sender...)
{
((Button)sender.Enabled = false;
// open the new form
..
((Button)sender.Enabled = true; // reenable the button
}
 

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