コード例 #1
0
        private void ExecuteOperation(Action <CslaOperation <T> > operationExecutor)
        {
            try
            {
                if (_lastOperation != null)
                {
                    _lastOperation.Cancel();
                }

                if (!IsConcurentRefreshesAllowed && _lastOperation != null)
                {
                    _nextOperationExecutor = operationExecutor;
                    return;
                }

                Error  = null;
                IsBusy = true;

                _lastOperation = new CslaOperation <T>(QueryCompleted);
                operationExecutor(_lastOperation);
            }
            catch (Exception ex)
            {
                Error  = ex;
                IsBusy = false;
            }
        }
コード例 #2
0
        private void QueryCompleted(DataPortalResult <T> result, bool isCanceled)
        {
            _lastOperation = null;

            if (!IsConcurentRefreshesAllowed && _nextOperationExecutor != null)
            {
                var executor = _nextOperationExecutor;
                _nextOperationExecutor = null;
                ExecuteOperation(executor);
                return;
            }

            if (isCanceled)
            {
                return;
            }

            try
            {
                if (result.Error == null)
                {
                    OnRefreshing(result.Object);
                    Model = result.Object;
                }
                else
                {
                    Error = result.Error;
                }
                OnRefreshed();
            }
            finally
            {
                IsBusy = false;
            }
        }