示例#1
0
        public OverseerWatcher(IPoller poller, IWatcher watcher)
            : base(watcher)
        {
            _reportedItems     = new HashSet <String>();
            _reportedFilesLock = new Object();

            InitPollerErrorPolicies();

            // Initiating poller
            _poller = poller;
            if (_poller.Path != watcher.Path)
            {
                _poller.Path = watcher.Path;
            }

            EnableRaisingEvents = false;

            _poller.Created += OnCreatedPolled;
            _poller.Deleted += OnDeletedPolled;
            _poller.Error   += OnPollerError;

            // Getting initial directory content by forcing a poll
            _poller.PollingType = PollingType.Poll;
            _poller.ForcePoll();

            // For the rest of the OverseerWatcher's lifespan, keep the poller as a 'watcher'
            _poller.PollingType = PollingType.Watch;
        }
示例#2
0
        protected override void OnError(Object sender, ErrorEventArgs e)
        {
            Exception ex = e.GetException();

            if (ex is InternalBufferOverflowException)
            {
                _poller.ForcePoll();
            }

            base.OnError(sender, e);
        }