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. Checking if an event is being handled

Checking if an event is being handled

Scheduled Pinned Locked Moved C#
help
5 Posts 3 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.
  • D Offline
    D Offline
    Dan Neely
    wrote on last edited by
    #1

    I've got an app that does heavy background processing off a user adjustable timer. If the tick rate is pushed too fast and all the CPU capacity is hogged by the background activity, or the app's running near the limit and annother process starts eating heavy cycles my app stops behaving well. The most prominant issue is that the form doesn't handle the OnPaint event. Is there an easy way to test that the event is being handled so that I can throttle the timer.

    M 1 Reply Last reply
    0
    • D Dan Neely

      I've got an app that does heavy background processing off a user adjustable timer. If the tick rate is pushed too fast and all the CPU capacity is hogged by the background activity, or the app's running near the limit and annother process starts eating heavy cycles my app stops behaving well. The most prominant issue is that the form doesn't handle the OnPaint event. Is there an easy way to test that the event is being handled so that I can throttle the timer.

      M Offline
      M Offline
      malikjhangirahmed hotmail com
      wrote on last edited by
      #2

      In source code, you can check by comparing that event against null. If the event is equal to null, it means corresponding event is not being handled. Otherwise, it is being handled.

      D 1 Reply Last reply
      0
      • M malikjhangirahmed hotmail com

        In source code, you can check by comparing that event against null. If the event is equal to null, it means corresponding event is not being handled. Otherwise, it is being handled.

        D Offline
        D Offline
        Dan Neely
        wrote on last edited by
        #3

        You misunderstand what I need. The default event handler for OnPaint is installed, but if the other stuff my app does in the background is being called to rapidly the event handler never actually gets called. I'm using a high precision win32 timer that IIUC uses a high priority kernal thread to repeatedly check a high precision clock and fire events to my app. If it's set too rapidly (and too rapid depends on the cpu speed and it's background process load), the timer itself can consume 100% of my app's cpu time, and my apps OnPaint event handler stops being executed.

        3 1 Reply Last reply
        0
        • D Dan Neely

          You misunderstand what I need. The default event handler for OnPaint is installed, but if the other stuff my app does in the background is being called to rapidly the event handler never actually gets called. I'm using a high precision win32 timer that IIUC uses a high priority kernal thread to repeatedly check a high precision clock and fire events to my app. If it's set too rapidly (and too rapid depends on the cpu speed and it's background process load), the timer itself can consume 100% of my app's cpu time, and my apps OnPaint event handler stops being executed.

          3 Offline
          3 Offline
          3Dizard
          wrote on last edited by
          #4

          I might get you wrong, too, but why don't you just add your own method to the event handler, which for example saves the time when it was executed in a variable, that you can check in your code. You might also override the OnPaint method of your form to do the above procedure: protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { lasttimeexecuted = DateTime.Now; base.OnPaint(e); } -- modified at 12:21 Wednesday 7th June, 2006

          D 1 Reply Last reply
          0
          • 3 3Dizard

            I might get you wrong, too, but why don't you just add your own method to the event handler, which for example saves the time when it was executed in a variable, that you can check in your code. You might also override the OnPaint method of your form to do the above procedure: protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { lasttimeexecuted = DateTime.Now; base.OnPaint(e); } -- modified at 12:21 Wednesday 7th June, 2006

            D Offline
            D Offline
            Dan Neely
            wrote on last edited by
            #5

            3Dizard wrote:

            I might get you wrong, too, but why don't you just add your own method to the event handler, which for example saves the time when it was executed in a variable, that you can check in your code.

            That sounds like it should work. Apparently my brain's been thinking it's friday 4:30pm all day. :doh::doh:

            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