Announcement

Collapse
No announcement yet.

How does Windows decide a program is "not responding"?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How does Windows decide a program is "not responding"?

    My app will be humming along moving motors and recording data, when Windows decides it's not responding. Usually takes about 5-10 seconds, or may not happen at all. My screen updates stop, but all my motion and data collections continues to work fine. When the activity is supposed to stop, it stops. Program flow goes back to the callback, the screen is updated and everything is normal again. No data is lost. This is one thread and just a series of calls to various instrument drivers, then data updates to text boxes.

  • #2
    Windows detects an app is "not responding" when the app's message queue is full (ie. you are running the app in a loop without allowing Windows to process messages). The best way around this (IMO) is to put your processing code in a second thread and disable the dialog that's running in the primary thread. The primary thread will then be able to process the message queue properly, while the second thread does it's work. That's basically all there is to it.
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      You can also throw a DIALOG DOEVENTS statement in your loop as well to help flush out the message queue...
      Adam Drake
      Drake Software

      Comment


      • #4
        Conrad,
        I thought it was to do with the windows message loop. When Windows sends your application a message it expects you to take it in a reasonable time. If you don't then Windows assumes the application is not responding.

        When you try to close an application, a WM_CLOSE notification will be sent to your program to tell it to close down. Again, if your program does not respond in a timely manner then Windows will offer the option to the user to forcibly terminate the application with the potential loss of data.

        Are you sure you keep responding to messages in your application's message queue while your data is being acquired?

        Paul.

        Comment


        • #5
          SendMessageTimeout() would be useful.
          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Thanks all- though it might not be the most sophisticated way, a dialog doevents in my loop solved the problem nicely! The loop typically runs in about 100 mS, but it runs continuously for up to a minute or two.

            Comment


            • #7
              Thanks all- though it might not be the most sophisticated way, a dialog doevents in my loop solved the problem nicely! The loop typically runs in about 100 mS, but it runs continuously for up to a minute or two.
              GUI + Worker Thread + Abort Demo 11-24-07
              Michael Mattias
              Tal Systems Inc. (retired)
              Racine WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Michael, I need to do it that way at some point, as an abort would be nice feature. Ok, an essential feature ;-) OTOH, the demo is longer than my entire app, and since my last fix and post, I've used the app to collect data on multiple parts, analyzed the data in a spreadsheet and written/distributed a report on those parts, so the quick fix was pretty successful!

                Comment


                • #9
                  > the demo is longer than my entire app...

                  I write with a lot of white space and comments.
                  Michael Mattias
                  Tal Systems Inc. (retired)
                  Racine WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Originally posted by Michael Mattias View Post
                    I write with a lot of white space and comments.
                    Among other things.

                    =====================================
                    "Alia jacta est." (The die is cast.)
                    JULIUS CAESAR
                    after crossing the Rubicon
                    =====================================
                    It's a pretty day. I hope you enjoy it.

                    Gösta

                    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                    Comment


                    • #11
                      >>I write with a lot of white space and comments.
                      >Among other things

                      Thank you for mentioning - even off-handedly - the flair, elan, and panache.

                      MCM
                      Michael Mattias
                      Tal Systems Inc. (retired)
                      Racine WI USA
                      [email protected]
                      http://www.talsystems.com

                      Comment


                      • #12
                        Originally posted by Michael Mattias View Post
                        >
                        Thank you for mentioning - even off-handedly - the flair, elan, and panache.

                        MCM
                        "off-handed"? Why, Michael, whatever do you mean? Those are exactly the qualities I was referring to.
                        It's a pretty day. I hope you enjoy it.

                        Gösta

                        JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
                        LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

                        Comment

                        Working...
                        X