I recently built a service uses a single thread to process information periodically. The service was built using Microsoft Visual Studio 2010 Express. I noticed the CPU usage took off to the moon (CPU usage at 100%).
Later, out of curiosity, I built a very small program, in which all it does is start a small thread, or timer, then runs some incredibly long loop. I also switched from building a console application to a Windows Form application. I was able to reduce my trouble by switching the type of program to build.
I've tried lowering the priority of the thread:
System.Threading.Thread.CurrentThread.Priority = ThreadPriority.Lowest;
I've also tried to set the priority class
Process p = Process.GetCurrentProcess();
p.PriorityClass = ProcessPriorityClass.BelowNormal;
I also thought that the CPU usage could've been high due to running on a virtual machine. But that theory didn't take me anywhere. It's pretty ridiculous. I don't know where else to turn. I'm not sure why starting a timer or a thread would send my CPU usage through the ceiling the way it does in the .NET framework. I never experienced this when building COM objects. Does anyone have any bright ideas as to where I can turn?
Thanks for your time in advance.