I need to call a webservice but I dont care if I get need a response or the service is down (fire and forget). Im currentlly using a try catch to compe with this.
My Question Is there a better way?
Thanks Sp
Bi开发者_开发知识库t more detail. I dont want the call to fail even if the webservice is down
This would be a great case for one-way or "fire and forget" serivces:
[ServiceContract]
interface IMyContract
{
[OperationContract(IsOneWay = true)]
void MyMethod()
}
Leaves the client with no need to mess with async hoo-ha, just make the call and get on with life.
string webServ = "addressofwebservice";
AsyncCallback asyncCall = new AsyncCallback(CallBack);
webServ.BeginSomeFunkyMethod(data, asyncCall, webServ);
...
private void CallbackSampleMethod(IAsyncResult asyncResult)
{
if(asyncResult != null)
{
doFunkyStuff();
}
// else I really don't care...
}
How about that ?
精彩评论