本文介绍了在继续代码 VB.net 之前等待 0.5 秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个代码,我希望它在继续之前在中间的某个地方等待.在 WebBrowser1.Document.Window.DomWindow.execscript("checkPasswordConfirm();","JavaScript") 之后我希望它等待 0.5 秒,然后执行其余代码.
I have a code and I want it to wait somewhere in the middle before going forward.After the WebBrowser1.Document.Window.DomWindow.execscript("checkPasswordConfirm();","JavaScript")I want it to wait .5 seconds and then do the rest of the code.
WebBrowser1.Document.Window.DomWindow.execscript("checkPasswordConfirm();","JavaScript")
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
For Each webpageelement As HtmlElement In allelements
If webpageelement.InnerText = "Sign Up" Then
webpageelement.InvokeMember("click")
End If
Next
推荐答案
您需要使用 System.Threading.Thread.Sleep(毫秒数).
WebBrowser1.Document.Window.DomWindow.execscript("checkPasswordConfirm();","JavaScript")
Threading.Thread.Sleep(500) ' 500 milliseconds = 0.5 seconds
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All
For Each webpageelement As HtmlElement In allelements
If webpageelement.InnerText = "Sign Up" Then
webpageelement.InvokeMember("click")
End If
Next
这篇关于在继续代码 VB.net 之前等待 0.5 秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!