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

problems with WCF service calls

2 Answers 99 Views
BusyIndicator
This is a migrated thread and some comments may be shown as answers.
Rocio
Top achievements
Rank 1
Rocio asked on 04 Oct 2012, 07:43 AM
Hello, I have a WCF Web Service, that makes a SQL query  to a data base and returns  a DataSet with the data.
In my WPF browser app I have a gridView and it's ItemsSource is the DataSet that the service returns, at first I got this code:

  if (grid.ItemsSource == null)
  {
      //Creates the reference for the duplex Service
      InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
      ServiceReference1.ServiceDuplexClient client2 = new ServiceDuplexClient(instanceContext);
       
      this.Cursor = System.Windows.Input.Cursors.Wait;
      //Call the service functon that returns the DataSet
      DataSet ds = client2.EventSummary();
      this.Cursor = System.Windows.Input.Cursors.Arrow;
 
      if (ds != null)
      {
          if (ds.DataSetName.Equals("OK"))
          {
              //If it's OK the DataSet is the ItemsSource of the grid
              grid.ItemsSource = ds;
          }
     }
}

It works fine, and does what it's supposed to do, the call to the service takes some moments, so I decided to change the cursor to a clock, but once I had it all working I like to change it for a busy indicator, so I added it to my code:

<telerik:RadBusyIndicator x:Name="busyIndicator" BusyContent="Loading data...." Grid.ColumnSpan="3" Grid.RowSpan="3">

a
public partial class Page1 : Page
{
   //Declare my background worker
    BackgroundWorker workerOperAct = new BackgroundWorker();
     
     public Page1()
     {
     InitializeComponent();
        workerOperAct.DoWork += this.WorkerOperActDoWork;
     workerOperAct.RunWorkerCompleted += WorkerOperActRunWorkerCompleted;
     }
     
     private void WorkerOperActDoWork(object sender, DoWorkEventArgs e)
    {
        //Create the reference for the service
        InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
     ServiceReference1.ServiceDuplexClient client2 = new ServiceDuplexClient(instanceContext);
        //Call the service function that returns the DataSet
     DataSet ds = client2.EventSummary();
     if (ds != null)
     {
          if (ds.DataSetName.Equals("OK"))
              {
                grid.ItemsSource = ds;
              }
      
}
  }
    void WorkerOperActRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {
        grid.Visibility = Visibility.Visible;
           this.busyIndicator.IsBusy = false;
    }
    //More code....
}

It's the same code, and it should work, but when I try to call the service:
DataSet ds = client2.EventSummary();

I get an exception:
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in Unknown Module.
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.

If I remove the busy indicator and the background worker it works fine and I can't understand what's happening, I have no clue,
I hope somebody can help me.
Thanks!!

2 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 09 Oct 2012, 09:35 AM
Hello Rocio,

I suggest to check this help article where we've explained how to integrate RadBusyIndicator with services.

If this does not help, please send us a sample runnable project demonstrating exactly the exception.

Regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Rocio
Top achievements
Rank 1
answered on 09 Oct 2012, 09:38 AM
Hello Yana, thanks for your response, I have read that article and follow it from the begining and everything worked right, I don't know what the problem was, but thanks!!
Tags
BusyIndicator
Asked by
Rocio
Top achievements
Rank 1
Answers by
Yana
Telerik team
Rocio
Top achievements
Rank 1
Share this question
or