c# - Asynchronous webservice in Asp.net -
how can set asynchronous web service in asp.net?
i want call webservice post data database, don't care if response failed or succeeded.
i can use .net 2.0 or 3.5 , can in vb or c#.
when create service reference in visual studio click "advanced..." button , check off "generate asynchronous operations". you'll have option make asynchronous calls against web service.
here's sample of both synchronous , same asynchronous call public web service.
// http://wsf.cdyne.com/weatherws/weather.asmx?wsdl using(var wf = new weatherforecasts.weathersoapclient()) { // example synchronous call wf.getcityforecastbyzip("20850"); // example asynchronous call wf.begingetcityforecastbyzip("20850", result => wf.endgetcityforecastbyzip(result), null); }
it might tempting call beginxxx
, not result since don't care it. you'll leak resources though. it's important every beginxxx
call matched corresponding endxxx
call.
even though have callback calls endxxx
, triggered on thread pool thread , original thread called beginxxx
free finish beginxxx
call done (it doesn't wait response).
Comments
Post a Comment