Reputation: 2198
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
Bit more detail. I dont want the call to fail even if the webservice is down
Upvotes: 1
Views: 687
Reputation: 15673
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.
Upvotes: 2
Reputation: 631
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 ?
Upvotes: 0