예제 #1
0
 /// <summary>
 /// Handles changes of the state of the watched path.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="pathAvailable"></param>
 private void WatchedPath_PathStateChangedEvent(WatchedPath sender, bool pathAvailable)
 {
     if (!pathAvailable && _watching)
     {
         DisableWatch();
     }
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the FileWatcher class, given the path to watch.
 /// </summary>
 /// <exception cref="NotSupportedDriveTypeException">
 /// The drive type of the specified path is not supported by the system.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// The parameter \"path\" is a null reference.
 /// </exception>
 /// <param name="path">The path to watch.</param>
 public FileWatcher(string path)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path", "The parameter \"path\" is a null reference.");
     }
     _syncNotify = new object();
     if (!IsValidDriveType(path))
     {
         throw new NotSupportedDriveTypeException("The drive type of \"" + path + "\" is not supported by the system.");
     }
     _subscriptions = new List <FileWatcherInfo>();
     _events        = new List <FileWatchEvent>();
     // Initialize the Component to watch the path's availability.
     _watchedPath = new WatchedPath(path, false);
     _watchedPath.PathStateChangedEvent += WatchedPath_PathStateChangedEvent;
 }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the FileWatcher class, given the path to watch.
        /// </summary>
        /// <exception cref="NotSupportedDriveTypeException">
        /// The drive type of the specified path is not supported by the system.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// The parameter \"path\" is a null reference.
        /// </exception>
        /// <param name="path">The path to watch.</param>
        public FileWatcher(string path)
        {
            if (path == null)
            {
                throw new ArgumentNullException("path", "The parameter \"path\" is a null reference.");
            }
            _syncNotify = new object();
            if (!IsValidDriveType(path))
            {
                throw new NotSupportedDriveTypeException("The drive type of \"" + path + "\" is not supported by the system.");
            }
            _subscriptions = new ConcurrentDictionary <FileWatcherInfo, DateTime>();
            _events        = new ConcurrentDictionary <FileWatchEvent, DateTime>();
            // Initialize the Component to watch the path's availability.
            _watchedPath = new WatchedPath(path, false);
            _watchedPath.PathStateChangedEvent += WatchedPath_PathStateChangedEvent;

            _notifyTimer          = new SystemTimer(EventsConsolidationInterval);
            _notifyTimer.Elapsed += NotifyTimer_Elapsed;
            _notifyTimer.Enabled  = true;
        }
예제 #4
0
 /// <summary>
 /// Handles changes of the state of the watched path.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="pathAvailable"></param>
 private void WatchedPath_PathStateChangedEvent(WatchedPath sender, bool pathAvailable)
 {
   if (pathAvailable && !_watching)
     EnableWatch();
   else if (!pathAvailable && _watching)
     DisableWatch();
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the FileWatcher class, given the path to watch.
 /// </summary>
 /// <exception cref="NotSupportedDriveTypeException">
 /// The drive type of the specified path is not supported by the system.
 /// </exception>
 /// <exception cref="ArgumentNullException">
 /// The parameter \"path\" is a null reference.
 /// </exception>
 /// <param name="path">The path to watch.</param>
 public FileWatcher(string path)
 {
   if (path == null)
     throw new ArgumentNullException("path", "The parameter \"path\" is a null reference.");
   _syncNotify = new object();
   if (!IsValidDriveType(path))
     throw new NotSupportedDriveTypeException("The drive type of \"" + path + "\" is not supported by the system.");
   _subscriptions = new List<FileWatcherInfo>();
   _events = new List<FileWatchEvent>();
   // Initialize the Component to watch the path's availability.
   _watchedPath = new WatchedPath(path, false);
   _watchedPath.PathStateChangedEvent += WatchedPath_PathStateChangedEvent;
 }