ContextSwitchDeadlock
-
Hi All, I'm slowing finding my way around C#. I have written an application that takes a directory, take each file in that directory and also each file in each subdirectory, and then trys to find any files with the same name (Trying to clear up all my duplicate photos :-) ) SO I have written the code, and checked it and checked it again, it does not get caught in an infinite loop. But when I F6 the app it comes up with a ContextSwitchDeadlock MDA issue. So I set the project Properties to "Fully Trusted" and now the app just goes I've added a progress bar that slowly grows - This works I also added a new text box and in the loop set the Text to the fileInfo.Name it was checking. But this does not update on the screen. Anyone have any ideas how I can Fix the: 1. Context switch/stop the screen blanking out. 2. Fix the Text box updating as it loops through. As always, thanks for looking and expecially thanks if you reply! Tony
-
Hi All, I'm slowing finding my way around C#. I have written an application that takes a directory, take each file in that directory and also each file in each subdirectory, and then trys to find any files with the same name (Trying to clear up all my duplicate photos :-) ) SO I have written the code, and checked it and checked it again, it does not get caught in an infinite loop. But when I F6 the app it comes up with a ContextSwitchDeadlock MDA issue. So I set the project Properties to "Fully Trusted" and now the app just goes I've added a progress bar that slowly grows - This works I also added a new text box and in the loop set the Text to the fileInfo.Name it was checking. But this does not update on the screen. Anyone have any ideas how I can Fix the: 1. Context switch/stop the screen blanking out. 2. Fix the Text box updating as it loops through. As always, thanks for looking and expecially thanks if you reply! Tony
The TextBox isn't updated cause the loop you're talking about probably runs on the main UI thread and therefor no other messages (e.g. change text of textbox) are processed until it is done. They are queued in the message pump and get executed after the event handler finishes. Take a look at the
Control.Refresh
method that forces a visual control to redraw itself immediately.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
The TextBox isn't updated cause the loop you're talking about probably runs on the main UI thread and therefor no other messages (e.g. change text of textbox) are processed until it is done. They are queued in the message pump and get executed after the event handler finishes. Take a look at the
Control.Refresh
method that forces a visual control to redraw itself immediately.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
-
Hi All, I'm slowing finding my way around C#. I have written an application that takes a directory, take each file in that directory and also each file in each subdirectory, and then trys to find any files with the same name (Trying to clear up all my duplicate photos :-) ) SO I have written the code, and checked it and checked it again, it does not get caught in an infinite loop. But when I F6 the app it comes up with a ContextSwitchDeadlock MDA issue. So I set the project Properties to "Fully Trusted" and now the app just goes I've added a progress bar that slowly grows - This works I also added a new text box and in the loop set the Text to the fileInfo.Name it was checking. But this does not update on the screen. Anyone have any ideas how I can Fix the: 1. Context switch/stop the screen blanking out. 2. Fix the Text box updating as it loops through. As always, thanks for looking and expecially thanks if you reply! Tony