My train of thought is N the loop, but found that takes up more than 50% of the CPU, have any good ideas?
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - line -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
And thought about the use of network IO delay to holding time, there's a better way
CodePudding user response:
Why don't sleep? You mean it is want to sleep, but not sleep? With no body is honesty to say, you this desire, the other hand, says he wants to, the body is to move back.If you don't want to block the main thread, then perform in a new thread, do not affect the main thread, or using asynchronous method.
CodePudding user response:
//introduction of high performance counter API, complete timing on CPU count[DllImport (" Kernel32. DLL)]
Private static extern bool QueryPerformanceCounter (out long lpPerformanceCount);
//get the current the working frequency of CPU
[DllImport (" Kernel32. DLL)]
Private static extern bool QueryPerformanceFrequency (out long lpFrequency);