每分钟刷新一次
答
您需要一个计时器对象才能每X分钟运行一次代码。使用单独的线程来检查Web服务只需要花费一些时间来检查并且希望表单在此期间保持响应。
使用计时器非常简单:
Private WithEvents timer As New System.Timers.Timer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Set interval to 1 minute
timer.Interval = 60000
'Synchronize with current form, or else an error will occur when trying to
'update the UI from within the elapsed event
timer.SynchronizingObject = Me
End Sub
Private Sub timer_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles timer.Elapsed
'Add code here to check if the web service is updated and update label
End Sub
首先 - 你为什么要保持网络服务开放的,如果你的不是真正使用它? – pingoo
类定时器下没有.SynchronizingObject方法 – Mwenyeji