System Tray Icon with background processes [modified]
-
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 theContextMenu
/Event
s. When the app' starts it should do nothing but sit there until the 'Start Sending'MenuItem
'sEvent
is called. This event starts a new Thread which checks a file repository betweenThread.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 theThread.Priority
toBelowNormal
but the applicationsThread
remains atNormal
in Task Manager. -- modified at 5:41 Wednesday 5th July, 2006 -
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 theContextMenu
/Event
s. When the app' starts it should do nothing but sit there until the 'Start Sending'MenuItem
'sEvent
is called. This event starts a new Thread which checks a file repository betweenThread.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 theThread.Priority
toBelowNormal
but the applicationsThread
remains atNormal
in Task Manager. -- modified at 5:41 Wednesday 5th July, 2006 -
Just make it sleep between the times it handles the messages:
while (this.Created) { Application.DoEvents(); Thread.Sleep(100); }
--- b { font-weight: normal; } -