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); }
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) { if (operation == null) { throw new ArgumentNullException("operation"); } if (operation.Action == null) { throw new ArgumentException("Delayed operation must have a callback.", "operation"); } if (operation.Id == null) { throw new ArgumentException("Delayed operation must have an Id.", "operation"); } lock (_lock) { // TODO(rpaquay): Consider a more efficient way if this becomes a bottleneck for (var node = _requests.First; node != null; node = node.Next) { if (node.Value.DelayedOperation.Id == operation.Id) { _requests.Remove(node); } } _requests.AddLast(new Entry { DateEnqeued = _dateTimeProvider.UtcNow, DelayedOperation = operation, }); _event.Set(); } }
public void Post(DelayedOperation operation) { var action = operation.Action; operation.Action = () => _synchronizationContextProvider.UIContext.Post(action); _delayedOperationProcessor.Post(operation); }
public void Post(DelayedOperation operation) { var action = operation.Action; operation.Action = () => _synchronizationContextProvider.DispatchThreadContext.Post(action); _delayedOperationExecutor.Post(operation); }
private void EnqueueOperation() { _sequenceNumber++; var operation = new DelayedOperation { Id = this.GetType().Name + "-" + _sequenceNumber, Delay = GetDelay(), Action = RunCheck }; _delayedOperationProcessor.Post(operation); }
public void Post(DelayedOperation operation) { if (operation == null) throw new ArgumentNullException("operation"); if (operation.Action == null) throw new ArgumentException("Delayed operation must have a callback.", "operation"); if (operation.Id == null) throw new ArgumentException("Delayed operation must have an Id.", "operation"); lock (_lock) { // TODO(rpaquay): Consider a more efficient way if this becomes a bottleneck for (var node = _requests.First; node != null; node = node.Next) { if (node.Value.DelayedOperation.Id == operation.Id) _requests.Remove(node); } _requests.AddLast(new Entry { DateEnqeued = _dateTimeProvider.UtcNow, DelayedOperation = operation, }); _event.Set(); } }
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); }
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); }