Exemplo n.º 1
0
        async void MediaSearchClickCommandExecute(RoutedEventArgs e)
        {
            var textValue = string.Empty;

            //텍스트 데이터 트림
            if (!string.IsNullOrWhiteSpace(SearchWord))
            {
                textValue = SearchWord.Trim().ToLower();
            }

            if (!SearchInResult)
            {
                SearchResultSource.Clear();
                await ThreadPool.RunAsync(async handler =>
                {
                    List <MediaInfo> resultList = new List <MediaInfo>();
                    fileDAO.SearchAllVideoList(resultList, textValue);

                    foreach (var mi in resultList)
                    {
                        await DispatcherHelper.RunAsync(() => {
                            SearchResultSource.Add(mi);
                        });
                    }
                });
            }
            else
            {
                for (int i = SearchResultSource.Count - 1; i >= 0; i--)
                {
                    var mii = SearchResultSource[i];
                    if (mii.Name.ToLower().IndexOf(textValue) == -1)
                    {
                        SearchResultSource.RemoveAt(i);
                    }
                }
            }
            CheckListButtonEnable = SearchResultSource.Count > 0;
        }
        private async Task ExecuteSearchCommand()
        {
            await Task.Factory.StartNew(() =>
            {
                Stopwatch stopwatch = null;
                stopwatch           = Stopwatch.StartNew();
                var foundedWords    = WordSearchHelper.ParallelFindWordsbySearchString(_wordListModel.Items, SearchWord.Trim());
                stopwatch.Stop();

                return(new SearchResultModel(CreateWords(foundedWords), stopwatch.Elapsed.TotalMilliseconds, SearchWord));
            }
                                        ).ContinueWith(task =>
            {
                Results = "------------------------------------------------------------------\n" +
                          "Suchwort: " + task.Result.SearchWord + "; Laufzeit: " + task.Result.SearchDuration + " Millisekunde(n)\n" +
                          task.Result.FoundedWords + Results;
            });
        }