我有这样的 Sub(),使用 GeckoWebBrowser 下载 HTML 页面
wb1 = Nothing
wb1 = New Gecko.GeckoWebBrowser
wb1.Navigate(v_url)
totalticks = 0
loadtimer.Start()
Do
If m_stop = True Then Exit Do
If wb1.IsBusy = False Then 'wb1.ReadyState = WebBrowserReadyState.Complete Then
If IsNothing(wb1.Document) = False Then
If IsNothing(wb1.Document.Body) = False Then
Exit Do
End If
End If
ElseIf wb1.IsBusy = True And String.IsNullOrEmpty(sucessID) = False Then 'wb1.ReadyState = WebBrowserReadyState.Interactive And String.IsNullOrEmpty(sucessID) = False Then
If IsNothing(wb1.Document) = False Then
If IsNothing(wb1.Document.Body) = False Then
If InStr(wb1.Document.Body.InnerHtml, sucessID, CompareMethod.Text) <> 0 Then
Exit Do
End If
End If
End If
End If
If totalticks = 15 Then
'wb1.Dispose()
wb1.Stop() 'wb1 = New System.Windows.Forms.WebBrowser
wb1.Reload(Gecko.GeckoLoadFlags.IsRefresh)
'wb1.ScriptErrorsSuppressed = True
'wb1.Navigate(v_url)
ElseIf totalticks >= 30 Then
wb1.Stop()
Exit Do
End If
'FreeUpMemory()
Application.DoEvents()
Loop
我的问题是 Application.DoEvents 需要很长时间才能处理和完成。PS 我正在使用 STA 线程来运行这个 Sub()