I have a WPF form with Next and Prev buttons for navigating to the next and previous months of a custom made calendar. I want to disable these buttons as soon as the user clicks on them and enable them when the mext/prev month data loads. That would prevent the user from clicking on the buttons repeatedly and the events queuing up and getting fired slowly one by one.
So far, I have tried putting the calendar data load stuff in a Dispatcher thread, and maintaining a flag to indicate whether the page is busy or not. Doesn’t seem to work, and the events still pile up.
I also tried using a command for the button clicks, have the execute handler load the data, and CanExecute decide whether data can be loaded, based on a IsBusy flag. Doesn’t work either.
Any pointers?
I fixed this by using a BackgroundWorker to load the view and checking BackgroundWorker.IsBusy in the next/prev event handlers.