Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. ContextSwitchDeadlock

ContextSwitchDeadlock

Scheduled Pinned Locked Moved C#
helpcsharpannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nooie
    wrote on last edited by
    #1

    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

    S N 2 Replies Last reply
    0
    • N Nooie

      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

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      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

      www.troschuetz.de

      N 1 Reply Last reply
      0
      • S Stefan Troschuetz

        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

        www.troschuetz.de

        N Offline
        N Offline
        Nooie
        wrote on last edited by
        #3

        Hi Stefen, Thanks for that. I swear I was looking for a Refresh method, but couldn't find it!. LOL. It worked anyway. Thanks! Tony

        1 Reply Last reply
        0
        • N Nooie

          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

          N Offline
          N Offline
          Nooie
          wrote on last edited by
          #4

          Gonna bump this as I'm still having the problem! Tony

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups