Пример #1
0
        /// <summary>
        /// Constructs a new instance of TimeDelayResultsReturner.
        /// </summary>
        /// <param name="searcher">
        /// The <see cref="Searcher"/> to use for obtaining results.
        /// </param>
        /// <param name="delay">
        /// The delay (in milliseconds) to wait between checks to
        /// see if there are new results from the
        /// <see cref="Searcher"/>.
        /// </param>
        public TimeDelayResultsReturner(Searcher searcher, int delay)
        {
            _searcher = searcher;

            _searcher.SearchFinished += SearchFinished;

            _timer = new Timer(delay) { AutoReset = false };

            _timer.Elapsed += CheckNow;
        }
Пример #2
0
        /// <summary>
        /// Indicates the <see cref="Searcher"/> has reported a
        /// finished state.
        /// </summary>
        /// <param name="sender">
        /// The <see cref="Searcher"/> reporting the event.
        /// </param>
        private void SearchFinished(Searcher sender)
        {
            _finished = true;

            _timer.Stop();

            if (Finished != null)
            {
                Finished.Invoke(_searcher.Matches);
            }
        }