Example #1
0
 public void StopSearch()
 {
     foreach (var cts in SearchingTasksCts)
     {
         cts?.Cancel();
     }
     SearchingTasksCts.Clear();
 }
Example #2
0
        public async Task <Task> TrySearchNextPageAsync()
        {
            var cts = new CancellationTokenSource(TimeSpan.FromSeconds(25));
            var t   = SearchNextPageAsync(cts.Token);

            SearchingTasksCts.Add(cts);
            try
            {
                await t;
            }
            catch (OperationCanceledException)
            {
                Extend.ShowMessage("搜索已取消");
            }
            catch (Exception ex)
            {
                Extend.ShowMessage(ex.Message, ex.ToString(), Extend.MessagePos.Window);
                Extend.Log(ex.Message, ex.StackTrace);
            }

            SearchingTasksCts.Remove(cts);
            return(t);
        }