views:

764

answers:

1

Is it possible to show a ProgressBar to show the Progress of a Webservice Call? I'm using a webservice which calls a SQL Database and returns, on demand, a List of the requested data.

Webservice Code

    public List<LocationUpdate> GetAllLocationsByUserID(int UserID)
    {
        MainframeConnectionDataContext db = new MainframeConnectionDataContext();
        var validLocations = from query in db.LocationUpdates select query;
        return validLocations.ToList();
    }

Client Code

    void Window1_Loaded(object sender, RoutedEventArgs e)
    {
        dg_sql_data.ItemsSource = CMainFrameConnection.GetAllLocationsByUserID(0);
    }

Currently it takes about 5-10 Seconds before the Data is loaded.

Any Ideas?

  • rAyt
+4  A: 

A progress bar might not be appropriate here as you presumably can't tell how far through the operation is. It might be more appropriate to display a 'loading' animation of some kind.

e.g. some example animations you could use here http://www.ajaxload.info/

EDIT: As Dreas points out, setting IsIndeterminate is a good way to handle this.

Steve Willcock
Good idea, goes in the right direction, but I think a progressbar should be possible if I call the webservice asynchronous.
Henrik P. Hessel
Yes, it's certainly possible to display a progress bar and animate it during an asynchronous call, but the problem is that because you don't know how far throught the operation is you can't make the progress bar accurate. You could simply loop the progress bar animation it so it fills up then empties, then fills up again to indicate that 'something' is happening.
Steve Willcock
in that case, just set IsIndeterminate="True"
Andreas Grech