Solved

C# Form 'stops working' if I switch to new window during process or change focus

Posted on 2011-02-22
3
311 Views
Last Modified: 2012-05-11
I have an application that I developed with c#.  The strange thing is that whilst the application is running, a lengthy process I might add, if I switch to another window or minimise or anything that makes the window lose focus, the form stops working, so to speak.

The process continues but until it finishes I cannot see anything.  The progress bar, for example, appears to stop working and may give an end user the impression the program has crashed, when it's not the case.

Why is this?
0
Comment
Question by:dbdp
[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
3 Comments
 
LVL 7

Expert Comment

by:kemi67
ID: 34952884
It seems like you need to insert some
Application.DoEvents();
in your code, to give control to other applications and so letting Windows be able to refresh progress bar.
For example
do
{
    someoperations;
    DoEvents();
    somedrawings;
   otheroperations;
}
while(finished);
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 34952921
You should consider having lengthy operations in a worker (or other) thread so the interface remains responsive.
0
 
LVL 13

Accepted Solution

by:
Naman Goel earned 500 total points
ID: 34953345
I already answered this question

please refer to following solution :

http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_26664806.html
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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