Beispiel #1
0
        /// <summary>
        /// Execute given query and show all entities in the result.
        /// </summary>
        /// <param name="query">Query to show</param>
        public async Task LoadQueryAsync(IExecutableQuery query)
        {
            // release all resources used by the previous query
            DisposeQuery();

            _selection.Clear();

            // start the query
            _queryEvaluator = _queryEvaluatorFactory.Create(query);
            View.Query      = _queryEvaluator.Query.Text;
            View.Items      = _queryEvaluator.Update();
            View.History.CanGoBackInHistory    = _queryHistory.Previous != null;
            View.History.CanGoForwardInHistory = _queryHistory.Next != null;
            View.BeginLoading();
            View.BeginPolling(PollingRate);

            try
            {
                await _queryEvaluator.RunAsync();

                if (!_isDisposed)
                {
                    View.UpdateItems();
                }
            }
            catch (OperationCanceledException)
            {
            }
            finally
            {
                if (!_isDisposed)
                {
                    View.EndLoading();
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Dispose all resources used by current query
 /// </summary>
 private void DisposeQuery()
 {
     _queryEvaluator?.Dispose();
     _queryEvaluator = null;
     View.Items      = null; // the items have been disposed by the query evaluator
 }