Locking my application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ashish Gupra
    New Member
    • Jun 2008
    • 14

    Locking my application

    Hi all,

    I want to lock my application if user does not interact with the application for specified time period.

    Is there any event or method to get that user does not interact/ use application for specific time?

    Regards,
    Ashish
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Not that I'm aware of. You'd need to set up a Timer, and a counter. Every tick, increment the counter, and check to see if it is past a preset value. If it is, do what you need to do to "lock" your app.

    The hard part is that I think you'd have to register another handler with every control on your form to detect activity. Or at least the controls that you think should count as remaining active. Then when that event is fired, you reset your counter to 0.

    That's how I'd do it anyway.

    Comment

    • nmsreddi
      Contributor
      • Jul 2006
      • 366

      #3
      Hello

      some one said that Timer control can solve the problem ,hope may be use full

      but how do you know when the timer should start, and if the user is back with in the expiry time you have to stop the timer? and after what time or when again you will start the Timer, i think it creates a complexity .

      Comment

      • alag20
        New Member
        • Apr 2007
        • 84

        #4
        Originally posted by nmsreddi
        Hello

        some one said that Timer control can solve the problem ,hope may be use full

        but how do you know when the timer should start, and if the user is back with in the expiry time you have to stop the timer? and after what time or when again you will start the Timer, i think it creates a complexity .
        Create a variable which records the last time when user interacted with your application, this could be mouse clicked / mouse position change / button clicked etc. Also make a timer control which checks when the last time the user interacted. If current time - the lasttime user interacted >= your lockout time, then you can simply lock your application. Leave the timer working even when the application is locked. Though this will take a bit of your resouce, but it will reduce the complexity and additional testing to stop / restart timer and stuff when the application is locked / unlocked.

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          There is an Application.Idl e event that might be usefull to you, but you'd probably be better off with a Timer/thread as mentioned above.

          Comment

          • Ashish Gupra
            New Member
            • Jun 2008
            • 14

            #6
            Originally posted by insertAlias
            Not that I'm aware of. You'd need to set up a Timer, and a counter. Every tick, increment the counter, and check to see if it is past a preset value. If it is, do what you need to do to "lock" your app.

            The hard part is that I think you'd have to register another handler with every control on your form to detect activity. Or at least the controls that you think should count as remaining active. Then when that event is fired, you reset your counter to 0.

            That's how I'd do it anyway.
            hi,

            Thanks for replying me...

            But i think this is not a good solution for a bulky application in which several forms are there. Because in this situation i think i have to handle mosue or keyboard activity in each form...

            Regards,
            Ashish

            Comment

            Working...