Refreshing AxWebBrowser in background while other browser is displayed

I have a simple program that navigates 4 browser windows to 4 different web sites and then after my timer elapses at 20 seconds the browser 1 will hide then 2 will show all the way through the 4 windows looping.  Problem is that I am sending a refresh command to the browser while it is in the background and the browser window does not refresh until it is visible again.  I have tried both AxWebBrowser.Refresh() and AxWebBrowser.Refresh2().  Refresh doesn't seem to work at all and Refresh2 will work but only when the browser is visible.  Here is code below.


 Private Sub Timer1_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
        On Error Resume Next

        Static intBrowserID As Integer = 0

        Select Case intBrowserID
            Case 0
                AxWebBrowser1.Visible = True
                AxWebBrowser2.Visible = False
                'AxWebBrowser2.Refresh2()
                AxWebBrowser3.Visible = False
                AxWebBrowser4.Visible = False
                AxWebBrowser4.Refresh2()
            Case 1
                AxWebBrowser1.Visible = False
                AxWebBrowser1.Refresh2()
                AxWebBrowser2.Visible = True
                AxWebBrowser3.Visible = False
                AxWebBrowser4.Visible = False
            Case 2
                AxWebBrowser1.Visible = False
                AxWebBrowser2.Visible = False
                AxWebBrowser2.Refresh2()
                AxWebBrowser3.Visible = True
                AxWebBrowser4.Visible = False
            Case 3
                AxWebBrowser1.Visible = False
                AxWebBrowser2.Visible = False
                AxWebBrowser3.Visible = False
                AxWebBrowser3.Refresh2()
                AxWebBrowser4.Visible = True
        End Select
        intBrowserID += 1
        If intBrowserID > 3 Then
            intBrowserID = 0
        End If

    End Sub
kevandjuAsked:
Who is Participating?
 
angelfeijooConnect With a Mentor Commented:
Kevandju,

"Refresh" is a method all controls have to redraw themselves to the screen. That has nothing to do with re-loading a website.

"Refresh2" reloads the website. As you found it seems that only actually starts reloading when the browser becomes visible again, thus is not helping your logic.

Assuming that all your browsers were one over the other so they show in the same place, do this:

        ....
        Select Case intBrowserID
            Case 0
                AxWebBrowser1.BringToFront
                AxWebBrowser4.Refresh2()
            Case 1
                AxWebBrowser1.Refresh2()
                AxWebBrowser2.BringToFront
            Case 2
                AxWebBrowser2.Refresh2()
                AxWebBrowser3.BringToFront
            Case 3
                AxWebBrowser3.Refresh2()
                AxWebBrowser4.BringToFront
        End Select
        ...
       
0
 
S-TwilleyCommented:
If refresh isn't working, what about navigating to it's own URL... soemthing like

AxWebBrowser.Navigate2(AxWebBrowser.LocationURL)

==========

if it doesn't register since it's the same URL, navigate away, and then back again

Dim locURL as string = AxWebBrowser.LocationURL
AxWebBrowser.Navigate2("")
AxWebBrowser.Navigate2(locUR)


0
 
S-TwilleyCommented:
sorry, it should have read:

Dim locURL as string = AxWebBrowser.LocationURL
AxWebBrowser.Navigate2("")
AxWebBrowser.Navigate2(locURL)
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
kevandjuAuthor Commented:
I'm trying it right now.  What exactly is the difference between .Navigate and .Navigate2?  I don't get what the 2 means.
0
 
Erick37Commented:
It may be related to this bug:

BUG: DocumentComplete Does Not Fire When WebBrowser Is Not Visible
http://support.microsoft.com/default.aspx?scid=kb;en-us;259935

Microsoft recommends not using an invisible WebBrowser, but instead position the WebBrowser control off-screen so it is not in view.
0
 
S-TwilleyCommented:
I believe navigate2 was an updated version of Navigate... but the old one was left in there for compatibility
0
 
kevandjuAuthor Commented:
That works perfectly angelfeijoo.  I already had the 4 browser windows overlayed.  I just didn't know about the bringtofront command.  Thanks for the insight!!
0
 
angelfeijooCommented:
You're welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.