Asynchronous web service
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.webservices.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Fritz
Let's suppose we have a client application, pushing a button we call
a webmethod asynchronously and inside the callback function we
manage the operation result. Something like this for instance:

private void button_Click(object sender, System.EventArgs e)
{
Service1 s=new Service1();
AsyncCallback cb = new AsyncCallback(this.HelloCallback);
IAsyncResult ar = s.BeginHello(textBox1.Text, cb, s);
}

private void HelloCallback(IAsyncResult ar)
{
Service1 s=(Service1)ar.AsyncState;
string result = s.EndHello(ar);
MessageBox.Show(result);
}

Let's suppose that the webmethod execution lasts for a long time, sufficient
to get an http connection timeout. At this time a WebException is raised.
The exception is not triggered by the execution of any of the previous
instructions but, as far as I can imagine, it is fired somewhere in a
parallel
thread which manages the asynchronous call.
The question is, how can I handle this kind of exceptions?

Thanks in advance.

--
Fritz

Reply to this message...
 
    
Vitaly Filimonov [MSFT] (VIP)
You can put try/catch block inside your callback function. Once you call
End...() you'll get SoapException generated for you.

--
Vitaly.
-------
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.

"Fritz" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.AsyncCallback
System.EventArgs
System.IAsyncResult
System.Net.WebException
System.Web.Services.Protocols.SoapException
System.Windows.Forms.MessageBox




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com