【发布时间】:2014-11-25 00:23:22
【问题描述】:
我正在使用以下方法成功地从网络检索数据:
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://www.example.org")
Dim o As Object
Dim dizi As String() = result.Split(New String() {",,,"}, StringSplitOptions.None)
' urls on the webpage are seperated with ,,, so it gets the first website
Dim urladdress As String = dizi(0)
o.Navigate2(urladdress)
但是,我需要为它添加时间循环。例如,它需要每 5 分钟检索一次数据。尝试了这个没有任何运气:
Imports System.Timers
Public Class TimerRequest
Private Shared aTimer As Timer
Private Shared o as Object
Public Shared Sub Main()
aTimer = New System.Timers.Timer(300000) ' 5 minutes
AddHandler aTimer.Elapsed, AddressOf OnTimedEvent
aTimer.Enabled = True
End Sub
Private Shared Sub OnTimedEvent(source As Object, e As ElapsedEventArgs)
'----------------------------------------
Dim webClient As New System.Net.WebClient
Dim result As String = webClient.DownloadString("http://www.example.org")
Dim o As Object
Dim dizi As String() = result.Split(New String() {",,,"}, StringSplitOptions.None)
' urls on the webpage are seperated with ,,, so it gets the first website
Dim urladdress As String = dizi(0)
o.Navigate2(urladdress)
'----------------------------------------
End Sub
End Class
这些是错误
![在此处输入图片描述][1]
这样做的正确方法是什么?
【问题讨论】:
-
without anyluck是什么意思?它会崩溃吗?计时器会触发吗?
标签: .net vb.net visual-studio-2010