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. Time out in application

Time out in application

Scheduled Pinned Locked Moved C#
csharphelp
11 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.
  • A Offline
    A Offline
    A T I F
    wrote on last edited by
    #1

    I need to implement a time-out feature in my Win 32 application developed in C#. I need to have some way that if there is not action on the application for say 10min it should ask for a re-login into the applications. Help!!! how!!!!

    S 1 Reply Last reply
    0
    • A A T I F

      I need to implement a time-out feature in my Win 32 application developed in C#. I need to have some way that if there is not action on the application for say 10min it should ask for a re-login into the applications. Help!!! how!!!!

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

      At first you should declare a bool, which determines whether a re-login has to be done or not and gets checked at the beginning of each handling of user interaction. Secondly start a timer, which switches the declared bool when elapsing, and reset it after each handling of an user interaction. I think the Threading.Timer class will be suitable here.


      www.troschuetz.de

      A 1 Reply Last reply
      0
      • S Stefan Troschuetz

        At first you should declare a bool, which determines whether a re-login has to be done or not and gets checked at the beginning of each handling of user interaction. Secondly start a timer, which switches the declared bool when elapsing, and reset it after each handling of an user interaction. I think the Threading.Timer class will be suitable here.


        www.troschuetz.de

        A Offline
        A Offline
        A T I F
        wrote on last edited by
        #3

        This is not at all simple.. I have the application that has about 50 dialogs all over....and many many user interaction handlers.....Do you think I will have to add timer resetter in all the user interaction handlers.... Is there any way to block all messages going to an application....main window and all subwindows...

        S 1 Reply Last reply
        0
        • A A T I F

          This is not at all simple.. I have the application that has about 50 dialogs all over....and many many user interaction handlers.....Do you think I will have to add timer resetter in all the user interaction handlers.... Is there any way to block all messages going to an application....main window and all subwindows...

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

          You could override the WndProc method of your main form or add a message filter to the message pump of your application by using Application.AddMessageFilter method.


          www.troschuetz.de

          A 2 Replies Last reply
          0
          • S Stefan Troschuetz

            You could override the WndProc method of your main form or add a message filter to the message pump of your application by using Application.AddMessageFilter method.


            www.troschuetz.de

            A Offline
            A Offline
            A T I F
            wrote on last edited by
            #5

            I did exactly that. it works fine for the main application form but when ever there is a model dialog popup the filter does not work on that window.....any idea why

            1 Reply Last reply
            0
            • S Stefan Troschuetz

              You could override the WndProc method of your main form or add a message filter to the message pump of your application by using Application.AddMessageFilter method.


              www.troschuetz.de

              A Offline
              A Offline
              A T I F
              wrote on last edited by
              #6

              I did exactly that. it works fine for the main application form but when ever there is a model dialog popup the filter does not work on that window.....any idea why :confused:

              S 1 Reply Last reply
              0
              • A A T I F

                I did exactly that. it works fine for the main application form but when ever there is a model dialog popup the filter does not work on that window.....any idea why :confused:

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

                Did you override the WndProc method or add a message filter? Do you pass the instance of your main form to the model dialogs (ShowDialog(this))?

                A 1 Reply Last reply
                0
                • S Stefan Troschuetz

                  Did you override the WndProc method or add a message filter? Do you pass the instance of your main form to the model dialogs (ShowDialog(this))?

                  A Offline
                  A Offline
                  A T I F
                  wrote on last edited by
                  #8

                  I used message filter. I did not override the WndProc but I did override the PreProcessMessage of the main form and it is called before WndProc (but it seems specific to the form) - no luck . :(( I did use ShowDialog(this)) for the child dialog. It seems that whenever we have a modal dialog other than the main form the events of the dialog goes directly to the dialog and not pass through the main form or application queue. Is this true? :confused: Atif

                  S 1 Reply Last reply
                  0
                  • A A T I F

                    I used message filter. I did not override the WndProc but I did override the PreProcessMessage of the main form and it is called before WndProc (but it seems specific to the form) - no luck . :(( I did use ShowDialog(this)) for the child dialog. It seems that whenever we have a modal dialog other than the main form the events of the dialog goes directly to the dialog and not pass through the main form or application queue. Is this true? :confused: Atif

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

                    I don't know exactly but here is my guess: I read again the documentation for the Application.AddMessageFilter method and found the following: "Message filters are unique to a specific thread." So I maybe the modal dialog runs with its own UI thread and therefor its message aren't detected by the filter. In this case you'll have to add a filter for every dialog. But as I said I'm not very sure about that, so open a new thread and gain from the knowledge of other CP's :)


                    www.troschuetz.de

                    A 1 Reply Last reply
                    0
                    • S Stefan Troschuetz

                      I don't know exactly but here is my guess: I read again the documentation for the Application.AddMessageFilter method and found the following: "Message filters are unique to a specific thread." So I maybe the modal dialog runs with its own UI thread and therefor its message aren't detected by the filter. In this case you'll have to add a filter for every dialog. But as I said I'm not very sure about that, so open a new thread and gain from the knowledge of other CP's :)


                      www.troschuetz.de

                      A Offline
                      A Offline
                      A T I F
                      wrote on last edited by
                      #10

                      I created another thread too...but it has not worked out yet...thanks a lot lot for all your help.

                      S 1 Reply Last reply
                      0
                      • A A T I F

                        I created another thread too...but it has not worked out yet...thanks a lot lot for all your help.

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

                        At first I want to apologize for the late answer. In my previous post I didn't suggest that you create another thread, but rather that for the opened modal dialog a new UI thread is created. Today, I checked this theory and it's false. The number of threads of an application stays the same when you open a modal dialog. So for me there is no obvious reason why the message filter didn't get notice of the messages for the modal dialog. Maybe you open a new thread with this specific problem, as surely another CP is able to provide a solution :)


                        www.troschuetz.de

                        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