Solved

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

Posted on 2011-02-22
3
309 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
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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…

839 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