punkouter
punkouter

Reputation: 5366

What is the correct and simplest way to check if a web service is available and not crash (windows phone 7)

Can I just do this below? Or is there a more proper way to do it ?

    ServiceReferenceSLHS.HighScoreWSClient client = new ServiceReferenceSLHS.HighScoreWSClient();
        client.GetHighScoresCompleted += new EventHandler<ServiceReferenceSLHS.GetHighScoresCompletedEventArgs>(client_GetHighScoresCompleted);

        try
        {
            client.GetHighScoresAsync();
        }
        catch (System.Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

Upvotes: 0

Views: 133

Answers (1)

Matt Lacey
Matt Lacey

Reputation: 65586

Your code will only capture errors generated when calling the method GetHighScoresAsync. It's normally very unlikely that you'll have sure exceptions.

It's much more likley that you want to capture exceptions in the callback function (client_GetHighScoresCompleted). Check the EventArgs there for errors.

Upvotes: 1

Related Questions