Beispiel #1
0
        public static bool CanUse()
        {
            TIMECAPS timeCaps = new TIMECAPS();
            int      result   = WinMM.timeGetDevCaps(ref timeCaps, Marshal.SizeOf(timeCaps));

            return(result != WinMM.TIMERR_NOERROR);
        }
 public static uint timeGetDevCaps(ref TIMECAPS timeCaps, uint sizeTimeCaps)
 {
     timeCaps = new TIMECAPS()
     {
         wPeriodMin = 10,
         wPeriodMax = uint.MaxValue,
     };
     return(MidiWinApi.MMSYSERR_NOERROR);
 }
Beispiel #3
0
        static TimerAPI()
        {
            ourLock = new object();

            var tc = new TIMECAPS();

            timeGetDevCaps(ref tc, Marshal.SizeOf(tc));
            ourMinPeriod   = tc.periodMin;
            ourMaxPeriod   = tc.periodMax;
            ourCurRequests = new List <int>();
        }
Beispiel #4
0
        /// <summary>
        /// Function to reset the timer.
        /// </summary>
        public void Reset()
        {
            TIMECAPS caps = default(TIMECAPS);

            if (_isHighResTimer)
            {
                if (Win32API.QueryPerformanceFrequency(out _frequency))
                {
                    Win32API.QueryPerformanceCounter(out _startTime);

                    return;
                }

                _isHighResTimer = false;
            }

            if (_timePeriod > 0)
            {
                if (Win32API.timeEndPeriod(_timePeriod) == TimePeriodReturn.NoCanDo)
                {
                    throw new Win32Exception(Resources.GOR_TIME_CANNOT_END);
                }
            }
            else
            {
                if (Win32API.timeGetDevCaps(ref caps, DirectAccess.SizeOf <TIMECAPS>()) != 0)
                {
                    throw new Win32Exception(Resources.GOR_TIME_CANNOT_BEGIN);
                }

                _timePeriod = caps.MinPeriod;
            }

            if (Win32API.timeBeginPeriod(_timePeriod) == TimePeriodReturn.NoCanDo)
            {
                throw new Win32Exception(Resources.GOR_TIME_CANNOT_BEGIN);
            }

            UsingLowResTimers = true;

            _startTick = Environment.TickCount;
            _startTime = Win32API.timeGetTime();
        }
Beispiel #5
0
 private static extern int timeGetDevCaps(ref TIMECAPS ptc, int cbtc);
 public static extern uint timeGetDevCaps(ref TIMECAPS timeCaps, uint sizeTimeCaps);
Beispiel #7
0
 public static extern int timeGetDevCaps(ref TIMECAPS ptc, int cbtc);
Beispiel #8
0
 public static extern MMRESULT timeGetDevCaps(out TIMECAPS ptc, uint cbtc = 8);