Question Displaying GIF image on Wait Form

CHUCKD

New member
Joined
Apr 20, 2011
Messages
3
Location
Vermont
Programming Experience
Beginner
I have a .net 4 form application. On a button click event, I want to open a form that has a GIF image in a webbrowser control, that says please wait. Then it opens a second form that has a datagridview that is being populated from a SQL query. Then I just hide the wait form. The reason I have resorted to this method is that sometimes it takes a while to display the results from with datagridview depending on what the user selected previously. The issue that I am having is the wait form displays but the GIF does not show up. If I make the application wait by using the following code the GIF show up like it supposed to until the timer runs out. At that point the image stops moving but is still present.

VB.NET:
Private Sub wait(ByVal interval As Integer)
        Dim sw As New Stopwatch
        sw.Start()
        Do While sw.ElapsedMilliseconds < interval
            ' Allows UI to remain responsive
            Application.DoEvents()
        Loop
        sw.Stop()
    End Sub

I am lost at this point, any help would be appreciated. My original intent was to use the show method to display the results form and then hide the previous form, but sometimes the previous form would close before I could display the results form.
 
Does using a PictureBox in instead of a WebBrowser make any difference?
 
The problem is you're tying up the UI thread with a long operation, this operation should be done in a background thread.
 
Back
Top