Solved

Screen redraaw problem

Posted on 2009-04-11
7
231 Views
Last Modified: 2013-11-27
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
0
Comment
Question by:jindalee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 24124413
Can you post the menu click event that kicks off the CPU intensive process?
0
 
LVL 1

Author Comment

by:jindalee
ID: 24124424
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

0
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 24124447
Try adding this line, Application.DoEvents(), to the code as shown in the code snippet.
   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"
        Application.DoEvents()   ' Add this line here
        dlgLoadProgress.Show()
        GetFiles(fileType)
        dlgLoadProgress.Close()
    End Sub

Open in new window

0
Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

 
LVL 1

Author Closing Comment

by:jindalee
ID: 31569260
That did the trick.  Any chance you could explain why?
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 24125566
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.
0
 
LVL 1

Author Comment

by:jindalee
ID: 24128355
Thank you. It is much better to understand what is happening than to just accept that it does the trick
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 24132075
Not a problem, I understand, glad I was able to help.  ;=)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question