Пример #1
0
        internal TimerQueueTimer(
            TimerQueue queue,
            TimerCallback cb,
            object state,
            uint dueTime,
            uint period,
            TimerQueueTimerFlags flags)
        {
            MyQueue  = queue;
            Callback = cb;
            win32WaitOrTimerCallback = TimerCallback;
            UserState = state;
            bool rslt = TQTimerWin32.CreateTimerQueueTimer(
                out Handle,
                MyQueue.Handle,
                win32WaitOrTimerCallback,
                IntPtr.Zero,
                dueTime,
                period,
                flags);

            if (!rslt)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error(), "Error creating timer.");
            }
        }
Пример #2
0
 public TimerQueue()
 {
     Handle = TQTimerWin32.CreateTimerQueue();
     if (Handle == IntPtr.Zero)
     {
         throw new Win32Exception(Marshal.GetLastWin32Error(), "Error creating timer queue.");
     }
 }
Пример #3
0
        public void Change(uint dueTime, uint period)
        {
            bool rslt = TQTimerWin32.ChangeTimerQueueTimer(MyQueue.Handle, ref Handle, dueTime, period);

            if (!rslt)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error(), "Error changing timer.");
            }
        }
Пример #4
0
 protected virtual void Dispose(bool disposing)
 {
     if (!disposed)
     {
         bool rslt = TQTimerWin32.DeleteTimerQueueTimer(MyQueue.Handle,
                                                        Handle, completionEventHandle);
         if (!rslt)
         {
             throw new Win32Exception(Marshal.GetLastWin32Error(), "Error deleting timer.");
         }
         disposed = true;
     }
 }
Пример #5
0
 protected virtual void Dispose(bool disposing)
 {
     if (!Disposed)
     {
         if (Handle != IntPtr.Zero)
         {
             bool rslt = TQTimerWin32.DeleteTimerQueueEx(Handle, CompletionEventHandle);
             if (!rslt)
             {
                 int err = Marshal.GetLastWin32Error();
                 throw new Win32Exception(err, "Error disposing timer queue");
             }
         }
         Disposed = true;
     }
 }