I am trying to call this webservice asynchrounously in vb.net. So on the aspx side i added this property async="true". Now on the vb.net code side i have this function inside my webservice tha开发者_开发百科t i am calling. So -
dim as as webservice.webstring
as.functionasync(param1, param2)
Now when i run the page, i can see that it wont call the webservice after a timegap. Should i add .thread.sleep()? Do i require the beginAsyn function and the EndAsyn function. I'm using asp.net 3.5 with IIS7
First, please read this MSDN article about how the asynchronous pages work in ASP.NET.
Second, you need to have an asynchronous method in your web-service. Please read this HOWTO article about how to create such methods.
This is how your implementation of the async page could look like:
private _as as WebService.WebString = Nothing
Public Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
AddOnPreRenderCompleteAsync(New BeginEventHandler(BeginCallingWebService),
New EndEventHandler(EndCallingWebService));
End Sub
Private Function BeginCallingWebService(Byval sender As Object, ByVal e As EventArgs, ByVal cb As AsyncCallback, ByVal state As Object)
_as = New WebService.WebString()
Return _as.BeginMyMethod(cb, state)
End Function
Private Sub EndCallingWebService(ByVal ar as IAsyncResult)
Dim result As MyWebServiceResult = _as.EndMyMethod(ar)
' Process the result of the web-service method
End Sub
Hope this will help you.
精彩评论