public RealTimeClock() { try { long filetime; Os.GetSystemTimePreciseAsFileTime(out filetime); IsHighResolution = true; } catch (EntryPointNotFoundException) { IsHighResolution = false; } }
/// <summary> /// A garbage-free implementation of the <see cref="Socket.Poll"/> function (only providing read polling). /// </summary> /// <param name="socket">The socket to poll.</param> /// <param name="descriptor">The socket descriptor.</param> /// <param name="microseconds">The duration to wait.</param> /// <returns>Whether there is data available to be read.</returns> internal static bool Poll(this Socket socket, IntPtr[] descriptor, int microseconds) { if (microseconds == 0) { return(socket.Available != 0); } var tv = new Os.TimeValue { Seconds = microseconds / 1000000, Microseconds = microseconds % 1000000 }; descriptor[0] = (IntPtr)1; descriptor[1] = socket.Handle; Os.select(0, descriptor, null, null, ref tv); return((int)descriptor[0] != 0 && descriptor[1] == socket.Handle); }