Exemplo n.º 1
0
        public void Post(DispatchThreadServerRequest 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.OnThreadPoolSend != null)
                    {
                        Logger.WrapActionInvocation(request.OnThreadPoolSend);
                    }

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

            _delayedOperationExecutor.Post(operation);
        }
        public void Post(DelayedOperation operation)
        {
            var action = operation.Action;

            operation.Action = () =>
                               _synchronizationContextProvider.DispatchThreadContext.Post(action);
            _delayedOperationExecutor.Post(operation);
        }
Exemplo n.º 3
0
 private void PostApplyFileSystemTreeToVsHierarchy(FileSystemTree fileSystemTree)
 {
     _delayedOperationExecutor.Post(
         new DelayedOperation {
         Id     = "ApplyFileSystemTreeToVsHierarchy",
         Action = () => ApplyFileSystemTreeToVsHierarchy(fileSystemTree),
         Delay  = TimeSpan.FromSeconds(0.1),
     });
 }
Exemplo n.º 4
0
        private void EnqueueOperation()
        {
            _sequenceNumber++;
            var operation = new DelayedOperation {
                Id     = this.GetType().Name + "-" + _sequenceNumber,
                Delay  = GetDelay(),
                Action = RunCheck
            };

            _delayedOperationExecutor.Post(operation);
        }
        private void ProxyOnEventReceived(TypedEvent typedEvent)
        {
            var evt = typedEvent as FileSystemScanFinished;

            if (evt != null)
            {
                if (evt.Error == null)
                {
                    _delayedOperationExecutor.Post(new DelayedOperation {
                        Id     = "FetchFileSystemTree",
                        Delay  = TimeSpan.FromSeconds(0.1),
                        Action = FetchFileSystemTree
                    });
                }
            }
        }