コード例 #1
0
        /// <summary>
        /// Starts collection of the given directory watcher and continues collecting all watchers
        /// which require collecting.
        /// </summary>
        /// <param name="directoryWatcher">The directory watcher to start collecting with</param>
        void CollectSequentially(DirectoryWatcher directoryWatcher)
        {
            // Bail out if we're already collecting. It will be picked up again later.
            if (this.IsCollecting())
            {
                return;
            }

            // Set callback and start collecting
            directoryWatcher.CollectingCompleted += directoryWatcher_CollectingCompleted;
            directoryWatcher.Collect();
        }
コード例 #2
0
        void directoryWatcher_CollectingCompleted(DirectoryWatcher directoryWatcher, int count)
        {
            // Remove callback
            directoryWatcher.CollectingCompleted -= directoryWatcher_CollectingCompleted;

            // Start watching
            directoryWatcher.Start();

            // Get next watcher to collect
            var toCollect = DirectoryWatchers.FirstOrDefault(dw => dw.CollectionState == CollectionState.CollectionRequired);

            if (toCollect != null)
            {
                CollectSequentially(toCollect);
            }
        }