Unable to switch task for Windows Form Application

396 Views Asked by At

I'm new to Visual Studio and C#. Just finished a Windows Form Application but detected following bugs. The program will dies (showing Not Responding) whenever user minimize/restores it, or switch to another task. This bug prevents user multitasking while running this program, so I really want to fix if. I wonder what are the possible causes of the problem, and how to solve them in general. I'd really appreciate any suggestion. Thanks!

2

There are 2 best solutions below

2
Peter Ritchie On

It could be anything where you have a long running loop or long running operation in your Form. The fact that you only see "not responding" when you minimize and restore is probably due to the fact that you've forced the window to redraw and forced Windows to recognize the app is hung and use the ghost window. The window was probably already hung before you minimized and restore it. You can verify this by trying to move the window. If it doesn't move, it's hung. If it does move, try to move the title bar off-screen and back (e.g. click in the middle of the title bar and drag it all the way to the right and release the button, then do the same and bring it back on screen).

0
Rezoan On

If i am not wrong you are running with a problem of UI freezing. if so why don't you use C# BackgroundWorker. it help you to prevent freezing the window form whether you doing a long task. you can find a good tutorial http://www.dotnetperls.com/backgroundworker here. Hope this will help.