This is a migrated thread and some comments may be shown as answers.

Show BusyInidcator

1 Answer 303 Views
BusyIndicator
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 05 Mar 2013, 02:06 PM

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();

        }

    }

1 Answer, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 08 Mar 2013, 09:35 AM
Hello Nick,

After reading your post I believe you try to show the RadBusyIndicator while the UI thread is frozen. The RadBusyIndicator like any other UIElement is rendered into the UI thread and this means that when the UI thread is frozen the RadBusyIndicator’s animation will freeze too. There is a possible workaround for this scenario demonstrated in this blog post.

Greetings,
Ivo
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
BusyIndicator
Asked by
Nick
Top achievements
Rank 1
Answers by
Ivo
Telerik team
Share this question
or