yes i looked with process explorer, and i saw 6 threads, with at least one consuming cpu time, but yes it's not as if it was 50% of cpu time, but it require the big .NET framework, using .net is not really suitable for just deleting a file every 5sec (without a big framework like that, you can make a program that use 1 thread, take 10 times less memory and the program file size was less that 10kb)
If you want to use .net, add some configuration window to let the user to choose the update time, delete also dump files, automatically restart the server on crashes
and i as see, there is more line of code using c# and .net for that than using C and windows API:
Code:
#include <windows.h>
#include <stdio.h>
int main() {
SYSTEMTIME sysTime;
while(1) {
if(DeleteFile("MemUsageInfo.txt")) {
GetLocalTime(&sysTime);
printf("[%02d:%02d:%02d] Memory Usage Info deleted\n", sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
}
Sleep(5000);
}
return 0;
}
if you want to exit when the user press a key, use PeekConsoleInput and GetStdHandle to know if there is data in stdin