There is a search button on the form I created. Press the Search button to perform the search under the specified conditions. Depending on the search conditions, the search may take a long time.
In this case, the foam thread stops temporarily. It doesn't matter because the time is not long. However, if the user continues to click the button while the form is still stationary, the search repeats as many times as the button was pressed after the search ends.
I want to prevent the click event when the user is searching by pressing the search button.
private void btSearch_Click(object sender, EventArgs e)
{
// check disabled button
if( !btSearch.Enabled )
return;
// disable button
btSearch.Enabled = false;
// long time searching...
// long time searching...
// long time searching...
// enable button
btSearch.Enabled = true;
}
I made the above code because I thought I could prevent the button from being pressed again by disabling it when I started searching. However, after the scan continues to complete, the scan is performed again as many times as you click during the scan.
Is there any way to prevent the event that the user clicked on while the UI thread is temporarily stopped?
UPDATE
I attached a video of the example program to clearly show my problem.