Beispiel #1
0
        public void Post(UIRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (request.Id == null)
            {
                throw new ArgumentException(@"Request must have an Id.", "request");
            }
            if (request.TypedRequest == null)
            {
                throw new ArgumentException(@"Request must have a typed request.", "request");
            }

            var operation = new DelayedOperation {
                Id     = request.Id,
                Delay  = request.Delay,
                Action = () => {
                    if (request.OnBeforeRun != null)
                    {
                        Logger.WrapActionInvocation(request.OnBeforeRun);
                    }

                    _typedRequestProcessProxy.RunAsync(request.TypedRequest,
                                                       response => OnRequestSuccess(request, response),
                                                       errorResponse => OnRequestError(request, errorResponse));
                }
            };

            _delayedOperationProcessor.Post(operation);
        }
Beispiel #2
0
        public void Post(UIRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            if (request.Id == null)
            {
                throw new ArgumentException(@"Request must have an Id.", "request");
            }
            if (request.Request == null)
            {
                throw new ArgumentException(@"Request must have a typed request.", "request");
            }

            var operation = new DelayedOperation {
                Id    = request.Id,
                Delay = request.Delay,
                // Action executed on a background thread when delay has expired.
                Action = () => {
                    if (request.OnSend != null)
                    {
                        Logger.WrapActionInvocation(request.OnSend);
                    }

                    _typedRequestProcessProxy.RunAsync(request.Request,
                                                       response => OnRequestSuccess(request, response),
                                                       errorResponse => OnRequestError(request, errorResponse));
                },
            };

            _delayedOperationProcessor.Post(operation);
        }
Beispiel #3
0
        public void Post(DelayedOperation operation)
        {
            var action = operation.Action;

            operation.Action = () =>
                               _synchronizationContextProvider.UIContext.Post(action);
            _delayedOperationProcessor.Post(operation);
        }
 private void PostApplyFileSystemTreeToVsHierarchy(FileSystemTree fileSystemTree)
 {
     _delayedOperationProcessor.Post(
         new DelayedOperation {
         Id     = "ApplyFileSystemTreeToVsHierarchy",
         Action = () => ApplyFileSystemTreeToVsHierarchy(fileSystemTree),
         Delay  = TimeSpan.FromSeconds(0.1),
     });
 }
Beispiel #5
0
        private void EnqueueOperation()
        {
            _sequenceNumber++;
            var operation = new DelayedOperation {
                Id     = this.GetType().Name + "-" + _sequenceNumber,
                Delay  = GetDelay(),
                Action = RunCheck
            };

            _delayedOperationProcessor.Post(operation);
        }
Beispiel #6
0
        private void ProxyOnEventReceived(TypedEvent typedEvent)
        {
            var @event = typedEvent as FileSystemTreeComputed;

            if (@event != null)
            {
                _delayedOperationProcessor.Post(new DelayedOperation {
                    Id     = "FetchFileSystemTree",
                    Delay  = TimeSpan.FromSeconds(0.1),
                    Action = FetchFileSystemTree
                });
            }
        }