问题描述
我刚刚制作了一个程序,我输入了一个代理列表,然后我的软件使用代理一遍又一遍地查看了一个 url.我在程序旁边使用网络浏览器,但速度很慢.所以我现在已经将代码更改为 htpp 请求.但是现在,当我运行该程序时,它会上升 2 倍,然后会变得 frezzes.这是我的代码
I have just made a program were i enter a proxy list then my software views a url over and over using the proxys . I was using a web browser in side the program but worked out slow.So i now have changed the code to htpp request. But now when i run the program it goes up by 2 the views then frezzes .Here is my code
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If ListBox1.Items.Count = 1 Then
Timer1.Enabled = False
MsgBox("All Proxies Used")
Else
Dim url As String = TextBox1.Text
UseProxy(ListBox1.Items(itemnumber))
Dim inStream As StreamReader
Dim webRequest As WebRequest
Dim webresponse As WebResponse
Dim url2 As New System.Uri(TextBox1.Text)
webRequest = webRequest.Create(url2)
webresponse = webRequest.GetResponse()
inStream = New StreamReader(webresponse.GetResponseStream())
Dim myRequest As WebRequest = webRequest.Create(url2)
Dim myResponse As WebResponse = myRequest.GetResponse()
myResponse.Close()
Label1.Text = ListBox1.Items.Count
WebBrowser1.ScriptErrorsSuppressed = True
Label6.Text = Label6.Text + 1
Label5.Text = ListBox1.Items.Count * 15 / 60 & " Minutes"
End If
End Sub
此外,我尝试只访问网站而不抓取任何使程序不崩溃但浏览量没有上升的任何内容
Also i try just going to the website and not grabing anything which makes the program not frezze but the views does not go up
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If ListBox1.Items.Count = 1 Then
Timer1.Enabled = False
MsgBox("All Proxies Used")
Else
Dim url As String = TextBox1.Text
UseProxy(ListBox1.Items(itemnumber))
Dim myRequest As WebRequest = WebRequest.Create(url)
Dim myResponse As WebResponse = myRequest.GetResponse()
myResponse.Close()
Label1.Text = ListBox1.Items.Count
WebBrowser1.ScriptErrorsSuppressed = True
Label6.Text = Label6.Text + 1
Label5.Text = ListBox1.Items.Count * 15 / 60 & " Minutes"
End If
End Sub
两个都试过了,都不行
推荐答案
试试这个:http://www.emoreau.com/Entries/Articles/2006/12/The-BackgroundWorker-component.aspx
这篇关于vb.net程序中的Http请求冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!