When the user clicks a button, an action is started but if the user quickly clicks the button 10 times, it will execute 10 times. I guess the disable doesn’t take effect until control returns from the event.
- (IBAction)btnQuickCheckClick:(id)sender {
@try {
self.btnQuickCheck.enabled = NO ;
// Next line takes about 3 seconds to execute:
[self pollRouter] ;
}
@finally {
self.btnQuickCheck.enabled = YES ;
}
}
You can update the UI by running the run loop after disabling the button before polling:
Of course, this method is no substitute for running a time intensive task on another thread. For long tasks, multithreading is almost always the way to go.