System.Diagnostics.Process.TicksToTimeSpan C# (CSharp) Method

TicksToTimeSpan() static private method

Convert a number of "jiffies", or ticks, to a TimeSpan.
static private TicksToTimeSpan ( double ticks ) : System.TimeSpan
ticks double The number of ticks.
return System.TimeSpan
        internal static TimeSpan TicksToTimeSpan(double ticks)
        {
            // Look up the number of ticks per second in the system's configuration,
            // then use that to convert to a TimeSpan
            long ticksPerSecond = Interop.Sys.SysConf(Interop.Sys.SysConfName._SC_CLK_TCK);
            if (ticksPerSecond <= 0)
            {
                throw new Win32Exception();
            }
            return TimeSpan.FromSeconds(ticks / (double)ticksPerSecond);
        }

Usage Example

Esempio n. 1
0
 private DateTime GetStartTime() => Process.BootTimeToDateTime(Process.TicksToTimeSpan(GetStat().starttime));