BusyIndicator not visible in some cases

2 posts, 0 answers
  1. yigal
    yigal avatar
    4 posts
    Member since:
    Dec 2013

    Posted 28 Jun Link to this post

    I'm using MVVM with property "IsBusy", set the DataContext to this property and change it when needed.

    The problem is that in some cases the BusyIndicator (BI) is not visible.

    Here is how the BI configured:

    <telerik:RadBusyIndicator x:Name="CashierBusyIndicator" IsBusy="{Binding IsBusy}" >                 <Style TargetType="telerik:RadBusyIndicator">

    The view model seems like that:

    public class CashierStationMainWindowModel : INotifyPropertyChanged
        {
     
            private bool _IsBusy;
     
            public bool IsBusy
            {
                get
                {
                    return _IsBusy;
                }
                set
                {
                    _IsBusy = value;
                    OnPropertyChanged("IsBusy");
                }
            }
     
            #region INotifyPropertyChanged implementation
            public event PropertyChangedEventHandler PropertyChanged;
     
            private void OnPropertyChanged(string propertyName = "")
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
            #endregion
        }

    The method that change the BI is:

    protected void EnableDisableBusyIndicatorAsync(bool enable)
        {
    CashierStationMainWindow.GetInstance().CashierStationWindowModel.IsBusy = enable;    
     }

    Simple not working example, this block is a button press implementation:

    EnableDisableBusyIndicatorAsync(true);
     
    System.Threading.Thread.Sleep(5000);
     
    EnableDisableBusyIndicatorAsync(false);

    Some more info:

    * The BI located at RadWindow object.

    * The not working block run from a RadPage located inside the RadWindow

    * Other RadPages call the EnableDisableBusyIndicatorAsync method and it works fine.

     

    Thanks in advanced,

    Eliran

     

  2. Nasko
    Admin
    Nasko avatar
    588 posts

    Posted 30 Jun Link to this post

    Hi Eliran,

    As any UI control RadBusyIndicator is rendered in the UI thread and if that thread is frozen it will not show as expected - as you have already observed when setting Sleep the UI thread gets frozen. You need to make sure that thread is not frozen when setting the IsBusy property of the control. Because of that we suggest you to use a BackgroundWorker in order to visualize the BusyIndicator as expected. We have created a sample project using the provided code-snippets that demonstrates how to show RadBusyIndicator using a BackgroundWorker.

    We hope this will help you.

    Regards,
    Nasko
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top