[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 325
  • Last Modified:

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

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
dbdp
Asked:
dbdp
1 Solution
 
kemi67Commented:
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
 
AndyAinscowCommented:
You should consider having lengthy operations in a worker (or other) thread so the interface remains responsive.
0
 
Naman GoelCommented:
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now