A
Amit
Hi
I have occured a very strange situation.
The scenario is as follows. I have two buttons in the form. First
button is Load button and the second one is Delete button. As the name
suggests when 'Load' button is clicked, some data is loaded on the
screen. When the Delete button is hit, this data is removed and the
user does not have access to it further. Load usually takes time and in
some extreme situations it takes 4-5 seconds to load the complete data.
User is not allowed to have Load and Delete operation being executed
simultaneously. Hence while the Load processing is going on, the Delete
button is disabled. Even though the user clicks on the disabled
(Delete) button, its handler is executed and the data is removed from
the screen.
The code in Load button click event handler looks like this:
void Load_Click()
{
DeleteButton.Enabled = false;
....
....
//Do heavy processing here
....
....
DeleteButton.Enabled = false;
}
Now consider this scenario. The user pressed Load button. It took 5
seconds to processing. In the first line, the Load button is disabled
and the button is indeed disabled visibly.
Within the 5 second time (i.e. during the Delete button is disabled),
the user clicks on the Delete button.
Now, the windows puts this Delete_Click event in the queue. After the
processing for Load_Click is done, it handles Delete_Click event. At
this time, it finds that the DeleteButton.Enabled is true (it was set
to true in the last statement of Load_Click). And hence it happily
executes the Delete_Click event handler and removes all the data from
the screen!!
Can anyone tell, how to resolve this situation? I require that the user
clicks should be ignored when the button is disabled.
Best regards
Amit Dedhia
I have occured a very strange situation.
The scenario is as follows. I have two buttons in the form. First
button is Load button and the second one is Delete button. As the name
suggests when 'Load' button is clicked, some data is loaded on the
screen. When the Delete button is hit, this data is removed and the
user does not have access to it further. Load usually takes time and in
some extreme situations it takes 4-5 seconds to load the complete data.
User is not allowed to have Load and Delete operation being executed
simultaneously. Hence while the Load processing is going on, the Delete
button is disabled. Even though the user clicks on the disabled
(Delete) button, its handler is executed and the data is removed from
the screen.
The code in Load button click event handler looks like this:
void Load_Click()
{
DeleteButton.Enabled = false;
....
....
//Do heavy processing here
....
....
DeleteButton.Enabled = false;
}
Now consider this scenario. The user pressed Load button. It took 5
seconds to processing. In the first line, the Load button is disabled
and the button is indeed disabled visibly.
Within the 5 second time (i.e. during the Delete button is disabled),
the user clicks on the Delete button.
Now, the windows puts this Delete_Click event in the queue. After the
processing for Load_Click is done, it handles Delete_Click event. At
this time, it finds that the DeleteButton.Enabled is true (it was set
to true in the last statement of Load_Click). And hence it happily
executes the Delete_Click event handler and removes all the data from
the screen!!
Can anyone tell, how to resolve this situation? I require that the user
clicks should be ignored when the button is disabled.
Best regards
Amit Dedhia