简体   繁体   中英

Async call of ASMX web service

In my scenario when ever user changes some fields in the program and does a SAVE , a webserivce request is sent to save some logging information into the database. I did some search on the website and found this solution for Async calls:

 ThreadPool.QueueUserWorkItem(delegate
 {
    // Create an instance of my webservice object.
    // call its Log webmethod.
 });

But since I don't have much experience with webservices and Async calls so I wanted to show you the scenario I have and the way I am handling it to get your opinion about it and if it the right way to do this. Thanks for suggestions.

Can you tolerate the logging work to be lost? Only then should you start "background work" in an ASP.NET app.

QueueUserWorkItem will work. The more modern version is Task.Run . Make sure you catch errors that happen on that thread-pool thread. If not, you'll never find out about bugs and silently lose work.

If you expect a high volume of such calls, or expect them to take a long time, consider using async IO . It does not use any thread while in progress (not even a background thread).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM