BusyIndicator before a radWindow

5 posts, 0 answers
  1. Cristian
    Cristian avatar
    7 posts
    Member since:
    Jun 2011

    Posted 05 Oct 2011 Link to this post

    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?
  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 07 Oct 2011 Link to this post

    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 >>
  3. DevCraft banner
  4. Cristian
    Cristian avatar
    7 posts
    Member since:
    Jun 2011

    Posted 10 Oct 2011 Link to this post

    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??

  5. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 12 Oct 2011 Link to this post

    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 >>
  6. Cristian
    Cristian avatar
    7 posts
    Member since:
    Jun 2011

    Posted 13 Oct 2011 Link to this post

    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!!
Back to Top
DevCraft banner