Пример #1
0
        public void SetTimer(DateTime wake)
        {
            this.Cancel();
            this.handle = WakeTimer.CreateWaitableTimer(IntPtr.Zero, true, "WaitableTimer");
            if (this.handle.ToInt32() == 0)
            {
                throw new Exception("復帰タイマーの設定に失敗しました。エラーコード = " + Marshal.GetLastWin32Error().ToString());
            }
            long num = (wake - DateTime.Now).Ticks * -1L;

            if (!WakeTimer.SetWaitableTimer(this.handle, ref num, 0, IntPtr.Zero, IntPtr.Zero, true))
            {
                throw new Exception("復帰タイマーの設定に失敗しました。エラーコード = " + Marshal.GetLastWin32Error().ToString());
            }
        }