Link to home
Start Free TrialLog in
Avatar of jindalee
jindalee

asked on

Screen redraaw problem

When I select a menu item to kick off a CPU intensive process, the process runs showing the progress dialog.

However, the menu remains displayed until the process has completed. (You can see what I mean in the attached image.)

How do I ensure that the menu disappears before the process kicks off?
ScreenError.jpg
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Can you post the menu click event that kicks off the CPU intensive process?
Avatar of jindalee
jindalee

ASKER

Here it is (in full):
   Private Sub ProgramsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProgramsToolStripMenuItem.Click
        DataGridView1.Rows.Clear()
        fontCount = 0
        dlgLoadProgress.Text = My.Resources.searchExecutableFile.ToString()
        fileType = "*.exe"
        dlgLoadProgress.Show()
        GetFiles(fileType)
        dlgLoadProgress.Close()
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That did the trick.  Any chance you could explain why?
What was happening is that the Window events that display and redraw the visuals on the screen were in the Windows Message Loop ready to be processed when the menu click event was called. This transfers control to the menu click event and does not return to process the remaing events until the menu click event has completed. By issueing a Application.DoEvents() this tells the OS to complete the processing of the events in the Windows Message Loop and return to the menu click event when that is done.
Thank you. It is much better to understand what is happening than to just accept that it does the trick
Not a problem, I understand, glad I was able to help.  ;=)