Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27055

WaitForPageLoad OR wait 3 seconds

$
0
0
Hi all,

I used a wait for page load function in the past, but now it seems to be not working after the website has been updated. Most of the content seems to be loaded, including the source, except for a few adverts that aren't shown. All I need is this source, so getting stuck because of an Ad is troubling me due to the WaitForPageLoad function below:

Code:

#Region "Page Loading Functions"
    Private Sub WaitForPageLoad()
        AddHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
        While Not pageready
            Application.DoEvents()
        End While
        pageready = False
    End Sub

    Private Sub PageWaiter(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
        If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then

            pageready = True
            RemoveHandler WebBrowser1.DocumentCompleted, New WebBrowserDocumentCompletedEventHandler(AddressOf PageWaiter)
        End If
    End Sub

#End Region

Is there a way I can use the faster of the two: waitForPageLoad or timer 3 seconds?

I tried the sleep command in the past, but it just freezes things up, and I'm not sure how to link from a button click function to a timer tick function properly.

Thanks

Viewing all articles
Browse latest Browse all 27055

Trending Articles