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

Global Busy Indicator?

4 Answers 257 Views
BusyIndicator
This is a migrated thread and some comments may be shown as answers.
Ramjet
Top achievements
Rank 1
Ramjet asked on 23 Apr 2012, 07:20 PM
Hello,

From my reading of this line "

When you are using the RadBusyIndicator control you always have to set its Content property. This will be the content on top of which you want to visualize the RadBusyIndicator control." in this article http://www.telerik.com/help/silverlight/radbusyindicator-getting-started.html I mocked up this quick demo to see if I could use it. WPF app loads a window. In the window is a frame which loads a page. On that page is a button that when clicked puts the thread to sleep for 3 seconds. In that button I get a handle to the parent window and set the IsBusy to true....but it never shows. I've tried numerous variations but I can't get it to work in my project or my mockup??

MainWindow:

<Window x:Class="LoadingTest.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <telerik:RadBusyIndicator x:Name="Thnk" IsBusy="false" telerik:StyleManager.Theme="Expression_Dark"  >
            <Frame Name="frm_BigBro" Grid.Row="0" Source="Page1.xaml" SnapsToDevicePixels="True" />
        </telerik:RadBusyIndicator>
    </Grid>
</Window>

Main Page cs

public void StartThinking()
        {
            Thnk.IsBusy = true;
        }
 
        public void StopThinking()
        {
            Thnk.IsBusy = false;
        }


Page1 XAML

<Grid>
    <TextBlock Text="My Page" />
    <Button x:Name="Button1" Click="Button1_Click" Width="80" Height="20" />
</Grid>

Page1 cs

private void Button1_Click(object sender, RoutedEventArgs e)
        {
            MainWindow wndow = new MainWindow();
 
            wndow = Window.GetWindow(sender as DependencyObject) as MainWindow;
            wndow.StartThinking();
 
            System.Threading.Thread.Sleep(3000);
 
            wndow.StopThinking();
 
        }

I'm sure it works so I must be doing something wrong?

TIA
JB

4 Answers, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 26 Apr 2012, 09:06 AM
Hi John,

When you are using Thread.Sleep the UI Thread is blocked and the BusyIndicator can not be displayed. We recommend doing such operation in a separate thread using BackgroundWorker. As an attached file you can find a simple project corresponding to the code you have sent.  Also you can take a look of this online demo.

Greetings,
Georgi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
ITA
Top achievements
Rank 1
answered on 19 Jun 2012, 11:35 AM
Hi,

this is great, but how does it work without the Button? I click on a Button in the MainWindow, in this MainWindow i have a frame and i want to show the page after it's loaded.

The main problem is to fill a RadGridView with ItemSource.

The Busyindicator is runnin well, but i can't bind the ItemSource to the Grid, during backgroundworker ist working. But how can i bind the ItemSource?

void Form_Loaded:
this.window = Window.GetWindow(sender as DependencyObject) as MainWindow;           
this.window.StartThinking();
 
var backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandlerbackgroundWorker_RunWorkerCompleted);
backgroundWorker.RunWorkerAsync();

void backgroundworker_DoWork:
// FileList = List<string>
FileList = winscp.GetFileNameInFolder(AktVerbindung, "spx", false);
QUELLEGrd.DataContext = FileList;
-- ERROR --

Error:
The calling thread can not access this object because the object is owned by another thread.

How can i solve this?

Thanks
Best Regrds
Rene
0
Georgi
Telerik team
answered on 20 Jun 2012, 06:36 AM
Hi Rene,

Form_Loaded should work for you instead of a button click. It seems like the only thing you need to do is use InvokeOnUIThread, in the example it looks like this :

private void OnBackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            var backgroundWorker = sender as BackgroundWorker;
            backgroundWorker.DoWork -= this.OnBackgroundWorkerDoWork;
            backgroundWorker.RunWorkerCompleted -= OnBackgroundWorkerRunWorkerCompleted;
 
            InvokeOnUIThread(() =>
            {
                this.IsBusy = false;
                this.Appointments = new ObservableCollection<Appointment>((IEnumerable<Appointment>)e.Result);
            });
        }

Can you, please give it a try and let us know if this works for you?


Regards,
Georgi
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
ITA
Top achievements
Rank 1
answered on 20 Jun 2012, 11:36 AM
Hi,

thanks that's it!

Regards
Rene
Tags
BusyIndicator
Asked by
Ramjet
Top achievements
Rank 1
Answers by
Georgi
Telerik team
ITA
Top achievements
Rank 1
Share this question
or