Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
A short film showing how OnPage and Connectwise integration works.
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

948 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now