Show BusyInidcator

2 posts, 0 answers
  1. Nick
    Nick avatar
    14 posts
    Member since:
    May 2011

    Posted 05 Mar 2013 Link to this post

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

            }

        }

  2. Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 08 Mar 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top