Example #1
0
        public static bool Enable(uint period = 1)
        {
            lock (thisLock)
            {
                if (!enabled)
                {
                    TimeCaps timeCaps = new TimeCaps();
                    uint     result   = NativeMethods.TimeGetDevCaps(ref timeCaps, (uint)Marshal.SizeOf(typeof(TimeCaps)));

                    if (result == 0)
                    {
                        period = Math.Max(period, timeCaps.wPeriodMin);
                        result = NativeMethods.TimeBeginPeriod(period);

                        if (result == 0)
                        {
                            lastPeriod = period;
                            enabled    = true;
                        }
                    }
                }

                return(enabled);
            }
        }
Example #2
0
 public static extern uint TimeGetDevCaps(ref TimeCaps timeCaps, uint sizeTimeCaps);