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. Global Application Events

Global Application Events

Scheduled Pinned Locked Moved C#
csharp
6 Posts 4 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.
  • L Offline
    L Offline
    leeoze 0
    wrote on last edited by
    #1

    Hi, I have a C# application which I need to recognize any user activity within the application only. This I do for the reason of timeout after zero activity. in the appliction I have differnet usercontrols. what I would like is when ever the user press key ,move mouse , or click to reset a timer. and if there is zero activity whith 20min to throw in a msg. tnks, Leeoze

    S M 2 Replies Last reply
    0
    • L leeoze 0

      Hi, I have a C# application which I need to recognize any user activity within the application only. This I do for the reason of timeout after zero activity. in the appliction I have differnet usercontrols. what I would like is when ever the user press key ,move mouse , or click to reset a timer. and if there is zero activity whith 20min to throw in a msg. tnks, Leeoze

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #2

      I'm not aware of a global event that does that. You'll have to respond to all the different events that you want to treat as activity, and call code to reset your timer from there. on a From there is a property called KeyPreview. If you set this to true, then key presses on controls on the form will also trigger the key events on the form as well. This will save you responding to key events on all controls. (There is an Application.Idle event that gets fired whenever the application has finished processing and is about to become idle. I don't think that will help you though)

      Simon

      L 1 Reply Last reply
      0
      • L leeoze 0

        Hi, I have a C# application which I need to recognize any user activity within the application only. This I do for the reason of timeout after zero activity. in the appliction I have differnet usercontrols. what I would like is when ever the user press key ,move mouse , or click to reset a timer. and if there is zero activity whith 20min to throw in a msg. tnks, Leeoze

        M Offline
        M Offline
        Muhammad Gouda
        wrote on last edited by
        #3

        All you need is a timer that counts down from 20m to 0 then reset the timer to 20 in each event (e.g. mouse move, button click, ...) when the timer reach 0, fire your msg

        Mohammed Gouda foreach(Minute m in MyLife) myExperience++;

        1 Reply Last reply
        0
        • S Simon P Stevens

          I'm not aware of a global event that does that. You'll have to respond to all the different events that you want to treat as activity, and call code to reset your timer from there. on a From there is a property called KeyPreview. If you set this to true, then key presses on controls on the form will also trigger the key events on the form as well. This will save you responding to key events on all controls. (There is an Application.Idle event that gets fired whenever the application has finished processing and is about to become idle. I don't think that will help you though)

          Simon

          L Offline
          L Offline
          leeoze
          wrote on last edited by
          #4

          Thx, It works just the way I needed. Application.Idle is the way.

          S 1 Reply Last reply
          0
          • L leeoze

            Thx, It works just the way I needed. Application.Idle is the way.

            S Offline
            S Offline
            Simon P Stevens
            wrote on last edited by
            #5

            Cool. Just don't do lots of processing in the Application.Idle because it gets fired everytime the app is about to go idle, so you'll just max out your cpu if you put lots of work in it because it will just keep getting called over and over.

            Simon

            L 1 Reply Last reply
            0
            • S Simon P Stevens

              Cool. Just don't do lots of processing in the Application.Idle because it gets fired everytime the app is about to go idle, so you'll just max out your cpu if you put lots of work in it because it will just keep getting called over and over.

              Simon

              L Offline
              L Offline
              leeoze 0
              wrote on last edited by
              #6

              if you use timer to count down then in each Tick the App fire the Idle event. then I would suggest not to count down rether use the intreval and fire your event on the Tick; Plus since there is cross-threading issue use Bool (i.e. ISTiCked) to set whether it has been ticked and in ur App.Idle even fucntion check for (true/fals) in ISTiCked.

              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