示例#1
0
        private void StartOperation(string searchText, int maxResults = Search.DefaultMaxResults)
        {
            Stopwatch sw            = Stopwatch.StartNew();
            var       results       = ExecuteSearch(searchText, maxResults);
            bool      moreAvailable = results is System.Collections.ICollection collection && collection.Count >= maxResults;
            var       elapsed       = sw.Elapsed;

            if (latestSearch == searchText)
            {
                DisplayResults?.Invoke(results, moreAvailable);
                SearchComplete?.Invoke(searchText, results, elapsed);
            }
        }
示例#2
0
        private void StartOperation(string searchText)
        {
            Stopwatch sw      = Stopwatch.StartNew();
            var       results = ExecuteSearch(searchText);
            var       elapsed = sw.Elapsed;

            BuildControl.Elapsed = elapsed;
            if (latestSearch == searchText)
            {
                Application.Current.Dispatcher.InvokeAsync(() =>
                {
                    DisplayResults?.Invoke(results);
                    SearchComplete?.Invoke(searchText, results);
                });
            }
        }
示例#3
0
        private void StartOperation(string searchText)
        {
            Stopwatch sw      = Stopwatch.StartNew();
            var       search  = new Search(Build);
            var       results = search.FindNodes(searchText);
            var       elapsed = sw.Elapsed;

            BuildControl.Elapsed = elapsed;
            if (latestSearch == searchText)
            {
                Application.Current.Dispatcher.InvokeAsync(() =>
                {
                    DisplayResults?.Invoke(results);
                });
            }
        }
示例#4
0
        private void StartOperation()
        {
            var cts = new CancellationTokenSource();

            Interlocked.Exchange(ref currentCancellationTokenSource, cts)?.Cancel();

            var localSearchText = searchText;
            var localMaxResults = maxResults;

            var sw      = Stopwatch.StartNew();
            var results = ExecuteSearch(localSearchText, localMaxResults, cts.Token);
            var elapsed = sw.Elapsed;

            var moreAvailable = results is System.Collections.ICollection collection && collection.Count >= localMaxResults;

            if (!cts.Token.IsCancellationRequested)
            {
                SearchComplete?.Invoke(localSearchText, results, elapsed);
                DisplayResults?.Invoke(results, moreAvailable);
            }
        }