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

BusyIndicator before a radWindow

4 Answers 62 Views
BusyIndicator
This is a migrated thread and some comments may be shown as answers.
Cristian
Top achievements
Rank 1
Cristian asked on 05 Oct 2011, 08:42 AM
Hello,

I have a Silverlight application with sensors (pushpins on a bing map). When the user clicks a sensor, I show a radwindow with a chart, and I want to show a busyIndicator in the time between the click and the radwindow is loaded, because at this lapse of time, the user could "touch" other application element( and I don't want to let it).

I've tried with this(among other things):

void sensor_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Dispatcher.BeginInvoke(() => uxbusyInd.IsBusy = true);
            uxbusyInd.IsBusy = true;
 
            sensorSeleccionado = (Pushpin)sender;
            MonitoringStation ms = (MonitoringStation)sensorSeleccionado.DataContext;
 
            AbreVentanaDetalle();           
 
        }
 
public void AbreVentanaDetalle()
        {
            VentanaDetalle vDetalle = new VentanaDetalle();
            vDetalle.ShowDialog();
        }
Any idea?

4 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 07 Oct 2011, 04:35 PM
Hi Cristian,

I can suggest you to use BackgroundWorker class in order to implement this. You could find an example how to achieve this in this online demo.

Hope this helps.

Greetings,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Cristian
Top achievements
Rank 1
answered on 10 Oct 2011, 09:56 PM
Hi Konstantina, and thanks for the reply.

I've tried to use the backgroundworker, but with an overloaded method "AbreVentanaDetalle":
public void AbreVentanaDetalle(DireccionesExternas de, Pushpin p)
        {
            DateTime fecha = DateTime.FromOADate(uxmarkerValorSensor.Value);
            VentanaDetalle vDetalle = new VentanaDetalle(de, p, swCon, listaTSSeleccionadas,
                fecha);
            vDetalle.Opened +=
                new RoutedEventHandler(vDetalle_Opened);
            vDetalle.ShowDialog();
        }

Now, the problem using backgroundworker is get the uxmarkerValorSensor value. The application throws an exception: "System.UnauthorizedAccessException: Acceso entre procesos no válido.", and the stacktrace:
en MS.Internal.XcpImports.CheckThread()
en System.Windows.DependencyObject.GetValueInternal(DependencyProperty dp)
en System.Windows.FrameworkElement.GetValueInternal(DependencyProperty dp)
en System.Windows.DependencyObject.GetValue(DependencyProperty dp)
en Telerik.Windows.Controls.Gauges.IndicatorBase.get_Value()
en SLMapaRTMN.MainPage.AbreVentanaDetalle(DireccionesExternas de, Pushpin p)
en SLMapaRTMN.MainPage.worker_DoWork(Object sender, DoWorkEventArgs e)
en System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
en System.ComponentModel.BackgroundWorker.OnRun(Object argument)

I need to configure the backgroundworker with some parameter??

0
Konstantina
Telerik team
answered on 12 Oct 2011, 04:39 PM
Hi Cristian,

Could you please give us some more details about this method - where is it used, etc? Also, if this code is called from the DoWork event handler of the BackgroundWorker you should put a Dispatcher around every UI operation, such as vDetalle.ShowDialog();
If you could send us some more code snippets, or ideally a sample running project we will be able to provide you with solution in a timely manner.

Greetings,
Konstantina
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Cristian
Top achievements
Rank 1
answered on 13 Oct 2011, 04:54 PM
Hi Konstantina,

finally, I solve my problem with a Dispatcher. I called "AbreVentanaDetalle(arg1, arg2)" from the Dowork event: 
void worker_DoWork(object sender, DoWorkEventArgs e)
{
   AbreVentanaDetalle(direcciones, sensorSeleccionado);
}
But this action throw me the exception I explained in my last post. Then, I've tried to call  "AbreVentanaDetalle(arg1, arg2)" with a dispatcher and it works!!
void worker_DoWork(object sender, DoWorkEventArgs e)
{
    try
    {
      Dispatcher.BeginInvoke(()=> AbreVentanaDetalle(direcciones, sensorSeleccionado));
    }
    catch (Exception ex)
    {
      string s = ex.Message;
    }
}
And in the event RunWorkerCompleted, I only set de busyIndicator to false:
void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
   Dispatcher.BeginInvoke(() => uxbusyInd.IsBusy = false);
}


Thanks for the help!!
Tags
BusyIndicator
Asked by
Cristian
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Cristian
Top achievements
Rank 1
Share this question
or