Пример #1
0
        public async Task CancelSearchAsync()
        {
            mCancellationTokenSource?.Cancel();
            Stopwatch st = new Stopwatch();

            st.Start();
            while (mSearchTask.IsCompleted == false && mSearchTask.IsCanceled == false && mSearchTask.IsFaulted == false)
            {
                await Task.Delay(1000);

                if (st.ElapsedMilliseconds > 5000)
                {
                    break;
                }
            }

            mCancellationTokenSource?.Dispose();
            mSearchTask = null;
            if (SearchCancelled != null)
            {
                SearchCancelled.Invoke(Tree, new EventArgs());
            }
            else
            {
                Reporter.HideStatusMessage();
            }
            Mouse.OverrideCursor = null;
        }
Пример #2
0
 private void _OnSearchCancelled(SearchResult results)
 {
     SearchCancelled?.Invoke(this, results);
 }