I am trying to build a code to get the website asynchronously using webclient.downloadstringasync
I want to pass the data thus retrieved from
to another function.
This is the code I am using,
dim myString as String Function GetSite(ByVal as URL as String) StartDownload(URL) WebBrowser1.DocumentText = mystring Retrun Nothing End Function Function StartDownload(ByVal URL As String) Dim _client As New Net.WebClient Dim URL As String If My.Computer.Network.IsAvailable Then _client.DownloadStringAsync(New Uri(URL)) End If AddHandler _client.DownloadStringCompleted, AddressOf DownloadStringCompleted Return Nothing End Function Function DownloadStringCompleted(ByVal sender As Object, _ ByVal e As system.Net.DownloadStringCompletedEventArgs) If e.Cancelled = False AndAlso e.Error Is Nothing Then myString = CStr(e.Result) End If Return myString End Function
My problem is that I am not being able to pass on the values as StartDownload gets completed, while data is still being retrieved. Any suggestions regarding the solution or work around would be greatly appreciated