My application is doing some simple reading and processing of CSV files on a background thread, set to highest thread priority. However, I notice that the process is dramatically slower when the application is not the active window. Even opening notepad makes the reading process about 10x slower, while the moment I click back to the application it speeds back up to the normal speed.
Is there any way to prevent the slowdown from happening? I thought using ThreadPriority was intended to achieve this, but it does not seem to have the desired effect.
Have tried the following:
Thread.CurrentThread.Priority = ThreadPriority.Highest;
System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime;
System.Diagnostics.Process.GetCurrentProcess().ProcessorAffinity = (IntPtr)0x0002;
ThreadPriority
define Priority of Threads within a Process. Have you try to up your Process priority?