sharp-chat/SharpChat/Win32.cs

25 lines
671 B
C#
Raw Normal View History

2022-08-30 15:05:29 +00:00
using System.Runtime.InteropServices;
namespace SharpChat {
public static class Win32 {
public static bool RunningOnWindows
=> RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
public static void IncreaseThreadPrecision() {
if(RunningOnWindows)
timeBeginPeriod(1);
}
public static void RestoreThreadPrecision() {
if(RunningOnWindows)
timeEndPeriod(1);
}
[DllImport(@"winmm")]
public static extern uint timeBeginPeriod(uint period);
[DllImport(@"winmm")]
public static extern uint timeEndPeriod(uint period);
}
}