Solved

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

Posted on 2011-02-22
3
301 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

15 Experts available now in Live!

Get 1:1 Help Now