终于会使用异步调用ws了,高兴啊
2004-10-25 17:17
309 查看
ws端
<WebMethod(Description:="异步调用演示")> _
Public Function HelloWorld(ByVal temp As String) As String
Return temp
End Function
客户端定义的新类
Public Class Class1
Private m_WsData As New localhost.Service1
Public Function beginhellow() As IAsyncResult
Try
Return m_WsData.BeginHelloWorld("下午好", Nothing, New Object)
Catch ex As Exception
MessageBox.Show("beginhellow发生错误!" & ex.Message & vbNewLine & ex.StackTrace)
Return Nothing
End Try
End Function
Public Function Endhellow(ByVal ar As IAsyncResult) As String
Dim temp As String
Try
Return m_WsData.EndHelloWorld(ar)
Catch ex As Exception
Return "Endhellow发生错误!" & ex.Message & ex.StackTrace
End Try
End Function
End Class
客户端使用
Dim temp As New Class1
Dim ar As IAsyncResult
ar = temp.beginhellow()
'ar.AsyncWaitHandle.WaitOne()
If (ar.IsCompleted) Then
Dim result As String
result = temp.Endhellow(ar)
TextBox1.Text = result
End If
<WebMethod(Description:="异步调用演示")> _
Public Function HelloWorld(ByVal temp As String) As String
Return temp
End Function
客户端定义的新类
Public Class Class1
Private m_WsData As New localhost.Service1
Public Function beginhellow() As IAsyncResult
Try
Return m_WsData.BeginHelloWorld("下午好", Nothing, New Object)
Catch ex As Exception
MessageBox.Show("beginhellow发生错误!" & ex.Message & vbNewLine & ex.StackTrace)
Return Nothing
End Try
End Function
Public Function Endhellow(ByVal ar As IAsyncResult) As String
Dim temp As String
Try
Return m_WsData.EndHelloWorld(ar)
Catch ex As Exception
Return "Endhellow发生错误!" & ex.Message & ex.StackTrace
End Try
End Function
End Class
客户端使用
Dim temp As New Class1
Dim ar As IAsyncResult
ar = temp.beginhellow()
'ar.AsyncWaitHandle.WaitOne()
If (ar.IsCompleted) Then
Dim result As String
result = temp.Endhellow(ar)
TextBox1.Text = result
End If
相关文章推荐
- 56. spring boot中使用@Async实现异步调用
- 脱离ws_ant直接使用Ant调用WebSphere编译器将jsp编译成class
- 使用@Async实现异步调用
- 在使用javascript-state-machine状态机调用异步钩子函数时,卡死问题及抛出异常问题
- C#使用异步方式调用同步方法
- 使用fscok实现异步调用PHP
- Ajax程序:处理异步调用中的异常(使用Asp.Net Ajax内建的异常处理方法)
- 使用Trigger让UpdatePanel外部的控件也支持无刷新异步调用
- Spring Boot中使用@Async实现异步调用
- spring-boot实战【10】【转】:Spring Boot中使用@Async实现异步调用
- Spring Boot中使用@Async实现异步调用
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法
- 线程锁 线程并发处理 | 异步调用委托的使用
- Spring Boot使用@Async实现异步调用:自定义线程池
- 使用ASP.NET AJAX异步调用Web Service和页面中的类方法(8):服务器端和客户端数据类型的自动转换:数组类型
- .NET 4.5 使用async和await关键字调用异步方法
- javascript 异步调用 后台.cs里的方法 PageMethods如何使用
- [置顶] Ajax程序:处理异步调用中的异常(使用Asp.Net Ajax内建的异常处理方法)
- android中使用异步调用google翻译接口翻译语句,并用译文替换显示到textView的原文
- 使用Trigger让UpdatePanel外部的控件也支持无刷新异步调用