How can I set up an asynchronous web service in asp.net?
I want to call a webservice to post some data to a database, but I don’t care if the response failed or succeeded.
I can use .net 2.0 or 3.5 only and it can be in vb or c#.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you create the service reference in visual studio click the “Advanced…” button and check off “Generate asynchronous operations”. Then you’ll have the option to make asynchronous calls against the web service.
Here’s a sample of both a synchronous and the same asynchronous call to a public web service.
It might be tempting to just call
BeginXxxand not do anything with the result since you don’t care about it. You’ll actually leak resources though. It’s important that everyBeginXxxcall is matched with a correspondingEndXxxcall.Even though you have a callback that calls
EndXxx, this is triggered on a thread pool thread and the original thread that calledBeginXxxis free to finish as soon as theBeginXxxcall is done (it doesn’t wait for the response).