After reading posts, looking at examples and trying everything I can think of I've finally decided to post.
The busyIndicator on my view doesn't show until after the work is done. Sometimes it never shows. I have a grid with multiple aggregate functions. It seems like IsBusy is set to true, data is retrieved, IsBusy is set to false, and the UI is locked until the aggregates have completed their calculation. Is there a better time to set IsBusy=false, like some event on the grid? I tried binding BusyIndicator.IsBusy to RadGridView.IsBusy, but it didn't make any difference. What I want, is to call the method below, immediately show the busy indicator, get the data, and hide the inidicator. The SetIsBusy method is called as part of a Task (TaskFactory.StartNew), thus the need for the Dispatcher to set IsBusy = value. But still, the inidicator does not immediately show. I have the DisplayAfter property set to 0.
What is the most reliable way to immediately show the busy indicator before loading the grid and the proper way to hide it after the aggregates have completed computation?
public void SetIsBusy(bool value, Func<ReadOnlyObservableCollection<TResult>> executeSearch)
{
Application.Current.Dispatcher.Invoke(new Action(() =>
{
IsBusy = value;
}), DispatcherPriority.Send, null);
if (this._IsBusy)
{
var backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler((object sender, DoWorkEventArgs e) =>
{
e.Result = executeSearch();
});
backgroundWorker.RunWorkerCompleted += OnExecuteSearchCompleted;
backgroundWorker.RunWorkerAsync();
}
}