Пример #1
0
 private void StopSearch(SearchCallbackShim callbackShim)
 {
     if (this.searchTask != null)
     {
         var localSearchTask = this.searchTask;
         this.searchTask = null;
         localSearchTask.Stop();
         //callbackShim?.Cancel();
     }
 }
Пример #2
0
        private Task StartSearch(string searchString, SearchCallbackShim callbackShim)
        {
            this.StopSearch(callbackShim: null);

            this.searchTask = searchProvider.CreateSearch(
                ++cookie,
                new SearchQueryShim(searchString),
                callbackShim);
            this.searchTask.Start();

            return(callbackShim.Task);
        }
Пример #3
0
        public System.Threading.Tasks.Task GetItemsAsync(
            string searchString,
            IOmniBoxSearchSession session)
        {
            if (session.CancellationToken.IsCancellationRequested)
            {
                return(Task.FromCanceled(session.CancellationToken));
            }

            var callbackShim = new SearchCallbackShim(session);

            session.CancellationToken.Register(() => this.StopSearch(callbackShim));

            return(this.StartSearch(searchString, callbackShim));
        }