示例#1
0
        private async void DoSearch(string query)
        {
            _searchUpdateIsRunning = true;
            cts = new CancellationTokenSource();

            FoundResults.Clear();

            IEnumerable <SearchResult> items = await Client.Search(query);

            foreach (SearchResult sr in items)
            {
                FoundResults.Add(new SearchResultDataItem()
                {
                    Name   = sr.Name,
                    GameId = sr.GameId
                });
            }

            // Separately load games through cache
            foreach (SearchResultDataItem srdi in FoundResults)
            {
                if (cts != null && cts.IsCancellationRequested)
                {
                    break;
                }

                BoardGameDataItem game = await LoadGame(srdi.GameId);

                if (game != null)
                {
                    srdi.Thumbnail = game.Thumbnail;
                }
            }

            cts = null;
            _searchUpdateIsRunning = false;
        }