예제 #1
0
		private static async void GetSuggestions(SearchSuggestionsRequestDeferral deferral, SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
		{
			try
			{
				var provider = GetProvider(sender);
				var query = args.QueryText;
				var suggestions = await Task.Run(() => provider.GetSuggestions(CancellationToken.None, query));
				var visitor = new AppendToSearchSuggestionCollectionVisitor(args.Request.SearchSuggestionCollection);
				foreach (var searchSuggestion in suggestions)
				{
					searchSuggestion.Accept(visitor);
				}
				deferral.Complete();
			}
			catch (Exception ex)
			{
				Debug.WriteLine(ex);
			}
		}
예제 #2
0
        private static async void GetSuggestions(SearchSuggestionsRequestDeferral deferral, SearchBox sender, SearchBoxSuggestionsRequestedEventArgs args)
        {
            try
            {
                var provider    = GetProvider(sender);
                var query       = args.QueryText;
                var suggestions = await Task.Run(() => provider.GetSuggestions(CancellationToken.None, query));

                var visitor = new AppendToSearchSuggestionCollectionVisitor(args.Request.SearchSuggestionCollection);
                foreach (var searchSuggestion in suggestions)
                {
                    searchSuggestion.Accept(visitor);
                }
                deferral.Complete();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }