My code on Windows used P/Invoke to call GetTickCount64()
from kernel32.dll This doesn't work under Mono on Ubuntu Server 14 - I get EntryPointNotFoundException
.
There's this approach using PerformanceCounter
. It works on Windows but when I use it on Linux with counter name/category set to System
/System Up Time
it yields zero timespans all the time. So it doesn't work too.
Environment.Tickount
works the same as on Windows but it overflows every 47 days and this can get confusing results for my usecase, so I'd prefer a 64-bit counter.
How do I get system uptime in C# code running with Mono on Ubuntu Server?