I use C# and Visual Studio 2012 to develop a WP8 application. I added a service reference to my project (Add Service Reference). So I am able to use webservice functions.
client = new YChatWebService.WebServiceControllerPortTypeClient();
client.getDataCompleted += client_getDataCompleted;
client.InnerChannel.OperationTimeout = new TimeSpan(0, 0, 0, 0, 500);
client.getDataAsync();
void client_getDataCompleted(object sender, getDataCompletedEventArgs e)
{
// e.Error.Message
}
I have set up a timeout limit 500ms for getData(); If the time limit is exceeded then I get following error:
“The HTTP request to ‘http://example.com/webService/index?ws=1’ has
exceeded the allotted timeout. The time allotted to this operation may
have been a portion of a longer timeout.”
That is nice 🙂 However, I would like to find out what kind of exception was thrown. Something like a string variable containing a string “TimeoutException” would be nice. How can I achive that?
You could use
To see if the Exception is of the type TimeoutException