コード例 #1
0
 private void WaitForChange(object state, bool timedOut)
 {
     bool flag = false;
     lock (this.NotificationLock)
     {
         this.RegisteredWait.Unregister(null);
         this.RegisteredWait = null;
         if (this.NotificationHandle.IsValid && this.NotificationHandle.Next())
         {
             this.RegisteredWait = ThreadPool.RegisterWaitForSingleObject(this.NotificationHandle, new WaitOrTimerCallback(this.WaitForChange), null, -1, true);
             flag = true;
         }
         else
         {
             this.NotificationHandle.Close();
             this.NotificationHandle = null;
         }
     }
     if (flag)
     {
         this.OnChanged(EventArgs.Empty);
     }
 }
コード例 #2
0
 private void Restart()
 {
     lock (this.NotificationLock)
     {
         this.Stop();
         this.NotificationHandle = new NotificationWaitHandle(this.FPath, this.FWatchSubdirs, this.FFilter);
         if (!this.NotificationHandle.Start())
         {
             this.NotificationHandle = null;
         }
         else
         {
             this.RegisteredWait = ThreadPool.RegisterWaitForSingleObject(this.NotificationHandle, new WaitOrTimerCallback(this.WaitForChange), null, -1, true);
         }
     }
 }
コード例 #3
0
 private void Stop()
 {
     lock (this.NotificationLock)
     {
         if (this.RegisteredWait != null)
         {
             this.RegisteredWait.Unregister(null);
         }
         this.RegisteredWait = null;
         if (this.NotificationHandle != null)
         {
             this.NotificationHandle.Close();
         }
         this.NotificationHandle = null;
     }
 }