Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
异步加载XML文件_Xml_Vb.net_Asynchronous - Fatal编程技术网

异步加载XML文件

异步加载XML文件,xml,vb.net,asynchronous,Xml,Vb.net,Asynchronous,我使用此函数使用Google Maps反向地理编码,并加载一个包含结果的XML: Private Function ReverseGeocode(ByVal Latitud As Double, ByVal Longitud As Double) As String Dim webClient As New System.Net.WebClient Dim sURL As String = "http://maps.googleapis.com/maps/api/geocode

我使用此函数使用Google Maps反向地理编码,并加载一个包含结果的XML:

Private Function ReverseGeocode(ByVal Latitud As Double, ByVal Longitud As Double) As String

    Dim webClient As New System.Net.WebClient
    Dim sURL As String = "http://maps.googleapis.com/maps/api/geocode/xml?latlng=@lat,@long&sensor=false"
    sURL = sURL.Replace("@lat", Latitud)
    sURL = sURL.Replace("@long", Longitud)

    Dim result As String = webClient.DownloadString(sURL)
    Dim xmlDoc As New XmlDocument()
    xmlDoc.LoadXml(result)

    Dim m_nodelist As XmlNodeList
    m_nodelist = xmlDoc.SelectNodes("/GeocodeResponse/result/formatted_address")
    ReverseGeocode = m_nodelist(0).InnerText
End Function

我的问题:这可以用异步方法完成吗?

可以。与
async
wait
一起使用异步版本的
DownloadString
。您可能需要使用
Task.Run
将长时间运行的计算移出UI线程(如果您有)