Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?
Save up to 50% on our desktop apps during our Year End Sale!Save up to 50% on our desktop apps during our Year End Sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save up to 50% on our desktop apps during our Year End Sale!

User Image
DAB42
31 discussion posts
I am currently using a while(true) { } too keep my elite journal reader program active but would like to make it less cpu intensive. any help or ideas would be greatly appreciated.

A Small delay of 1ms does improve CPU usage dramatically but some events are missed during the wait time.

Code

public static void ReadLog()
        {
        // creat event watcher    
     
            FileSystemWatcher watcher = new FileSystemWatcher();
            watcher.Path = logpath;
            watcher.NotifyFilter = NotifyFilters.LastWrite; 
           NotifyFilters.FileName;         
            // Add event handlers.
            watcher.Changed += new FileSystemEventHandler(OnChanged);
       
            // Begin watching.
            watcher.EnableRaisingEvents = true;
         
            //infinite loop
            while(true)
            {
               BFS.VoiceBotActions.Delay(1);
            }
        }
Nov 30, 2018 (modified Dec 1, 2018)  • #1
Keith Lammers (BFS)'s profile on WallpaperFusion.com
The only way really would be to use thread sleeps, like you did. If you try BFS.General.ThreadWait(1) instead, does that work better?
Dec 4, 2018  • #2
User Image
DAB42
31 discussion posts
Thank you Keith

Did try threadwait but that seemed to slow the entire script and the watchers did not work.

the cpu usage has improved greatly using delay dropping form 13 percent to less then 3 so happy with the improvement
Dec 4, 2018  • #3
Keith Lammers (BFS)'s profile on WallpaperFusion.com
Ok, sounds good!
Dec 4, 2018  • #4
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)