private void HandleNewRequests() { var requests = RequestRepository.GetNewRequests(); if (requests.Count > 0) { foreach (var r in requests) { //Todo: make sure the request is ready to start and use cancel token if needed r.Status = RequestStatus.Ready; } Logger.WriteInfo($"Made {requests.Count} requests in ready state"); } }
private void HandleIncomingReadyRequests() { int currentCount = _list.Count; if (currentCount < 10) { int amountToAdd = 10 - currentCount; var readyRequests = RequestRepository.GetOpenRequests().Take(amountToAdd); readyRequests.ToList().ForEach(r => { RequestProcessor proc = new RequestProcessor(r); proc.RequestRepository = RequestRepository; AddNewRequestProcessor(proc); proc.Process(); Logger.WriteInfo($"Request {r.Id} started"); }); } }