Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

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(-)