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. System Tray Icon with background processes [modified]

System Tray Icon with background processes [modified]

Scheduled Pinned Locked Moved C#
sysadminhelptutorialquestion
4 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.
  • S Offline
    S Offline
    synunn
    wrote on last edited by
    #1

    Hi kids :) Background I'm writing a system service style application. It consists of a NotifyIcon in the sys'tray that has several functions that are called from the ContextMenu/Events. When the app' starts it should do nothing but sit there until the 'Start Sending' MenuItem's Event is called. This event starts a new Thread which checks a file repository between Thread.Sleep(15*60*1000). Problem To cut to the chase, the application is maxing out the cpu usage during a loop: while(this.Created){ Application.DoEvents();} How to I prevent this excesive usage? Do I need to access the System Idle Process? This usage doesn't actually halt the server or even slow it down it just capitalizes the usage as there is no other contender for the cpu's attention. I have tried to drop the Thread.Priority to BelowNormal but the applications Thread remains at Normal in Task Manager. -- modified at 5:41 Wednesday 5th July, 2006

    G 1 Reply Last reply
    0
    • S synunn

      Hi kids :) Background I'm writing a system service style application. It consists of a NotifyIcon in the sys'tray that has several functions that are called from the ContextMenu/Events. When the app' starts it should do nothing but sit there until the 'Start Sending' MenuItem's Event is called. This event starts a new Thread which checks a file repository between Thread.Sleep(15*60*1000). Problem To cut to the chase, the application is maxing out the cpu usage during a loop: while(this.Created){ Application.DoEvents();} How to I prevent this excesive usage? Do I need to access the System Idle Process? This usage doesn't actually halt the server or even slow it down it just capitalizes the usage as there is no other contender for the cpu's attention. I have tried to drop the Thread.Priority to BelowNormal but the applications Thread remains at Normal in Task Manager. -- modified at 5:41 Wednesday 5th July, 2006

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Just make it sleep between the times it handles the messages: while (this.Created) { Application.DoEvents(); Thread.Sleep(100); } --- b { font-weight: normal; }

      S 1 Reply Last reply
      0
      • G Guffa

        Just make it sleep between the times it handles the messages: while (this.Created) { Application.DoEvents(); Thread.Sleep(100); } --- b { font-weight: normal; }

        S Offline
        S Offline
        synunn
        wrote on last edited by
        #3

        I thought that too but it causes a crash, The problem is that Events don't stack up between each Sleep so you have to click during the split second that Application.DoEvents(); is running :omg: -- modified at 12:34 Thursday 6th July, 2006 Not to worry though, I found a solution

        G 1 Reply Last reply
        0
        • S synunn

          I thought that too but it causes a crash, The problem is that Events don't stack up between each Sleep so you have to click during the split second that Application.DoEvents(); is running :omg: -- modified at 12:34 Thursday 6th July, 2006 Not to worry though, I found a solution

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Yes, the messages are queued. If the program crashes, there is something else that causes that. --- b { font-weight: normal; }

          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