public void FindNewsRelations(CancellationToken token) { var task = new Task(() => { if (token.IsCancellationRequested) { return; } for (int i = 0; i < NewsResultCollection.ResultList.Count; i++) { ResultModel record = NewsResultCollection.ResultList[i]; StatusInfo = String.Format("Searching '{0}' ...", record.Content); var data = VectorFinder.Find(record.Content, token); record.ResultCollection.ResultList.Clear(); if (data == null) { return; } foreach (var r in data) { record.ResultCollection.ResultList.Add(r); } if (token.IsCancellationRequested) { return; } } ReloadNewsSignal = true; StatusInfo = "Ready"; StatusColor = 0; IsSearching = false; }); task.Start(); }
private void SearchCommand_Executing(object sender, ExecutingEventArgs e) { if (String.IsNullOrWhiteSpace(ResultCollection.SearchContent) || IsLoading) { return; } StatusInfo = String.Format("Searching '{0}' ...", ResultCollection.SearchContent); StatusColor = 1; if (IsSearching) { CToken.Cancel(); CToken = new CancellationTokenSource(); } IsSearching = true; var data = VectorFinder.FindWord(ResultCollection.SearchContent, CToken.Token); ResultCollection.ResultList.Clear(); if (data == null) { return; } int i = 0; foreach (var record in data) { ResultCollection.ResultList.Add(record); record.Index = String.Format("{0}.", ++i); } IsBeginSearching = true; ReloadSignal = true; FindRelations(CToken.Token); }
private void LoadPageVectorsAsync() { var task = new Task(() => { IsLoading = true; StatusInfo = "Loading page vectors..."; try { VectorFinder.LoadPageVectors(); } catch (IOException e) { StatusInfo = e.Message; StatusColor = 2; return; } StatusInfo = "Ready"; IsLoading = false; StatusColor = 0; //SearchCommand.Execute(null); }); task.Start(); }