coolcurrent4u Posted June 21, 2011 Posted June 21, 2011 i have this code, with only one url at first, which seems to freeze the UI for about a minutes. i wanted to get the web page html faster asynchronously, but this is not working for me Is the httpwebrequest faster? Private Sub Test(ByVal sender As Object, ByVal e As DownloadStringCompletedEventArgs) Dim newstring As String = e.Result.ToString listBox1.Items.Add ("Finished" & e.UserState.ToString) End Sub Sub Button1Click(sender As Object, e As EventArgs) for each item as String in textbox1.Lines Dim SiteURI As New Uri(item) Dim wc As New WebClient wc.DownloadStringAsync(SiteURI) AddHandler wc.DownloadStringCompleted, AddressOf Test next End Sub Quote
Administrators PlausiblyDamp Posted June 21, 2011 Administrators Posted June 21, 2011 When you say it isn't working what exactly happens? Is it failing in any way or just not getting the results? Using HttpWebRequest might be slightly faster but probably not significantly so in comparison - the biggest factor is probably going to be the bandwidth between the server and client more than anything. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
coolcurrent4u Posted June 21, 2011 Author Posted June 21, 2011 it freeze the GUI, but it returns the string i thought async is not suppose to freeze the GUI? Quote
Administrators PlausiblyDamp Posted June 22, 2011 Administrators Posted June 22, 2011 It shouldn't freeze the GUI using the Async call, I just tried it on my PC here and I did notice the line listBox1.Items.Add ("Finished" & e.UserState.ToString) was throwing a null reference exception due to UserState being null, but once I removed that part it ran just fine with no hanging of the UI in the slightest. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.