Devlico.Us
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @devlicious

Derik Whittaker

Thoughts on Software Development, .Net, OOP, Design Patterns and all things cool



Using Anonymous Delegates to handle Async Web Service Calls

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, 



Comments

Using Anonymous Delegates to handle Async Web Service Calls said:

Pingback from  Using Anonymous Delegates to handle Async Web Service Calls

# October 15, 2007 10:24 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Derik Whittaker

Derik is a .Net Developer/Architect specializing in WinForms working out the northern suburbs of Chicago. He is also believer and advocate for Agile development including SCRUM, TDD, CI, etc.

When Derik is not writing code he can be found spending time with his wife and young son, climbing on his bouldering wall, watching sports (mostly baseball), and generally vegging out. Check out Devlicio.us!

Our Sponsors

Proudly Partnered With


This Blog

Syndication

News