I just thought I would share a little trick I used today to back in Async web
service calls into existing code using anonymous delegates.
Here was my problem:
I have a library that makes use of
an existing web service that I do not control (so I cannot change/up the timeout on this). I have been using this code now
for a few weeks with no issues, however late last week I noticed that I was
experiencing timeouts when making certain requests via the service. My original
code was making use of the synchronous methods on the web service. In order to
get around the time out issue I wanted to make the calls asynchronous, but I did
not want to have to put in a ton of time or effort to retrofit my code.
Here is my solution:
Create an anonymous delegate to
handle my Async call and move on.
Here is my original code
Here is the new code using the delegates
As you can see, this code is not 'slick' and 'cool' but it does do the job. By tweaking this code I was able to not have to re-write any other outside logic to handle the new async way of making this call.
Till next time,