public FileItemManager(CommentTaskProvider provider, FileMonitor monitor, Options options)
        {
            this.provider = provider;
            this.monitor  = monitor;

            this.options          = options;
            this.options.Applied += this.Options_Applied;
            this.RefreshExcludePatterns();
        }
        public CommentTaskProvider(MainPackage package)
            : base(package.ServiceProvider)
        {
            this.ServiceProvider     = package.ServiceProvider;
            package.Options.Applied += this.Options_Applied;

            // In some cases the task list may not be available (e.g., during devenv.exe /build).
            IVsTaskList taskList = this.ServiceProvider.GetService(typeof(SVsTaskList)) as IVsTaskList;

            if (taskList == null)
            {
                this.disposed = true;
            }
            else
            {
                // Register a custom category so Visual Studio will invoke our IVsTaskListEvents callbacks.
                VSTASKCATEGORY[] assignedCategory = new VSTASKCATEGORY[1];
                int hr = this.VsTaskList.RegisterCustomCategory(CategoryId, (uint)TaskCategory.Comments + 1, assignedCategory);
                ErrorHandler.ThrowOnFailure(hr);
                this.CustomCategory = (TaskCategory)assignedCategory[0];

                // The TaskProvider.ProviderGuid Property help says:
                // "The task list groups all tasks from multiple providers with the same GUID into a single list."
                // So the ProviderGuid is really just the group we're providing tasks for and not unique to us.
                this.ProviderGuid = ProviderId;
                this.ProviderName = "Tasks (" + MainPackage.Title + ")";

                // Hide this provider since we're using our own Tasks tool window.
                this.AlwaysVisible            = false;
                this.DisableAutoRoute         = false;
                this.MaintainInitialTaskOrder = false;

                this.foregroundTimer          = new System.Windows.Forms.Timer();
                this.foregroundTimer.Interval = (int)TimeSpan.FromSeconds(1).TotalMilliseconds;
                this.foregroundTimer.Tick    += this.ForegroundTimer_Tick;
                this.ScanDelay = TimeSpan.FromSeconds(2);

                this.CacheCommentTokens();
                this.solutionMonitor = new SolutionMonitor(this);
                this.documentMonitor = new DocumentMonitor(this);
                this.fileMonitor     = new FileMonitor(this);
                this.manager         = new FileItemManager(this, this.fileMonitor, package.Options);

                // Enable the timers last.  The BackgroundTimerCallback will fire after ScanDelay (on a worker thread),
                // so we have to ensure that everything is initialized before its first callback.
                this.foregroundTimer.Enabled = true;
                this.backgroundTimer         = new System.Threading.Timer(this.BackgroundTimerCallback, null, this.ScanDelay, this.ScanDelay);
            }
        }