打印本文 打印本文 关闭窗口 关闭窗口
ASP.NET创建Web服务之异步Web服务
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1586  更新时间:2009/4/23 10:33:00  文章录入:mintao  责任编辑:mintao
llAuthors.authors.Rows(i)
 If (row("au_lname").ToString() = state.Author) Then
  found = True
 End If
 i = i + 1
End While

If (found) Then
 Dim cb As AsyncCallback = state.originalCallback
 ' Calls the second XML Web service, because the author is
 ' valid.
 rs.BeginReturnedStronglyTypedDS(state.Author, cb, state)
Else
 ' Cannot throw the exception in this function or the XML Web
 ' service will hang. So, set the state argument to the
 ' exception and let the End method of the chained XML Web
 ' service check for it.
 Dim ex As ArgumentException = New ArgumentException( "Author does not exist.", "Author")
 Dim cb As AsyncCallback = state.originalCallback
 ' Call the second XML Web service, setting the state to an
 ' exception.
 rs.BeginReturnedStronglyTypedDS(state.Author, cb, ex)
End If
End Sub

' Define the End method.
<WebMethod()> _
Public Function EndGetAuthorRoyalties(ByVal asyncResult As _
IAsyncResult) As localhost.AuthorRoyalties
 ' Return the asynchronous result from the other XML Web service.
 Return remoteService.EndReturnedStronglyTypedDS(asyncResult)
End Function

End Class

' Class to wrap the callback and state for the intermediate asynchronous
' operation.
Public Class AsyncStateChain
Public originalCallback As AsyncCallback
Public originalState As Object
Public Author As String
End Class
End Namespace

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口