After pressing the 'x' button in a window, the contents of my window black out and then I have to press the 'x' a second time to close down the program completely. Anyone know why this is?
Asked
Active
Viewed 138 times
1
-
4Going to be pretty hard to diagnose without some sample code - anything happening on your application exit? Any multi-threading going on etc? – Charleh Dec 04 '12 at 16:27
-
Or, are you doing anything on the window closing, window close event handlers? – Ravi Y Dec 04 '12 at 16:27
-
8No, we don't know why, but you will once you use a debugger. – Ben Voigt Dec 04 '12 at 16:30
-
Alas, I have tried the debugger but to no avail – MrBretten Dec 04 '12 at 16:46
-
1@Charleh, It was a thread. I was able to close it and the program is working properly. I'll vote you up if you write it to the answers – MrBretten Dec 04 '12 at 16:47
-
Just give the upvotes to csharptest, I've been typing all day and I'm worn out :) – Charleh Dec 04 '12 at 16:49
1 Answers
3
This is how Windows behaves when an application is not responding. I'm guessing you have some work ongoing in the main UI thread that is blocking the Form from responding to the Close event.
When you are performing a long-running operation in WinForms you should consider using a BackgroundWorker. This will allow the Form to update and respond correctly.
-- edit --
Sorry just saw you are in WPF not WinForms. Same principal applies though. See also this question: How to use WPF Background Worker

Community
- 1
- 1

csharptest.net
- 62,602
- 11
- 71
- 89