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
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
Can you post the menu click event that kicks off the CPU intensive process?
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
ASKER
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. ;=)