我在客户端应用程序上配置了 wcf 服务引用。它提供了一系列功能来检索和发送数据到基于 Web 的数据库。举个例子:
Function errorCodesGetAll(ByVal uname As String, ByVal pword As String) As String
和
Function errorCodesGetAllAsync(ByVal uname As String, ByVal pword As String) As System.Threading.Tasks.Task(Of String)
我知道我可以使用以下代码使用第一个函数填充富文本框:
RichTextBox1.Text = getCountryList
Private Function getCountryList() As String
Dim svc As New ServiceReference2.ERSAPIServiceClient
svc.Open
Dim str As String = svc.errorCodesGetAll(username, password)
svc.Close()
Return str
End Function
由于 WCF 对我来说仍然是一个非常新的领域,我想知道如何填充相同的富文本框,但这次使用 errorCodesGetAll 函数的 Async 变体?
感谢您就如何最好地使用异步变体提供任何建议或一般指示。