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

How does IsBusyIndicationVisible work ?

1 Answer 111 Views
BusyIndicator
This is a migrated thread and some comments may be shown as answers.
Chaitanya
Top achievements
Rank 1
Chaitanya asked on 09 Aug 2012, 08:46 PM
I have a situation where I need to know when the RADBusyIndicator is unloaded. The IsBusy is binded to a property 'ShowMessage' and when I do in the code behind:


public void foo()
{
        obj.ShowMessage = false; //Set IsBusy binded property in View Model names 'obj' to false
        
        while (busyIndicator.IsBusyIndicationVisible)
                { System.Threading.Thread.Sleep(100);}

        //--------- Code to execute after BusyIndicator unloaded
}

However this does not work and code goes into an infinite loop at the while.

Next I executed:

while (busyIndicator.IsBusyIndicationVisible)
                { System.Threading.Thread.Sleep(100);}

        //--------- Code to execute after BusyIndicator unloaded

In a separate thread, but that also does not work which is very strange. I seems BusyIndicator blocks on every access to busyIndicator.IsBusyIndicationVisible property.

Any workaround will be very helpful.

Thanks,
Chait

1 Answer, 1 is accepted

Sort by
0
Ivo
Telerik team
answered on 14 Aug 2012, 07:17 AM
Hi Chait,

The IsBusyIndicatorVisible property is set to false when the RadBusyIndicator's fade out animation finishes. By sleeping the thread you block the UI thread and the fade out animation never gets the chance to be played so it never finishes. However I tested this using another thread and it worked as expected. Here is the sample code I used:
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var viewModel = (ViewModel)this.DataContext;
 
            viewModel.IsBusy = false;
 
            Thread backgroundThread = new Thread(new ThreadStart( () =>
            {
                while (this.IsBusyIndicatorVisible())
                {
                    System.Threading.Thread.Sleep(100);
                }
            }));
 
            backgroundThread.Start();
        }
 
        private bool IsBusyIndicatorVisible()
        {
            bool isBusy = true;
 
            this.Dispatcher.Invoke(new Action(() =>
            {
                isBusy = BusyIndicator.IsBusyIndicationVisible;
            }));
 
            return isBusy;
        }


Regards,
Ivo
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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