private void ProcessResult(TestUnitWithMetadata test, AgentMetadata agent, TestResult result) { bool isRequestCompleted; using (agents.Lock()) { lock (tests.SyncObject) { AddResultsToTestUnitMetadata(test, result); tests.MarkCompleted(test); agents.MarkAsReady(agent); reprocessor.AddForReprocessingIfRequired(test, result, agent); isRequestCompleted = !tests.IsAnyAvailableFor(test.Test.Run); } } results.Add(result, test.Test.Run); var request = requests.GetBy(test.Test.Run); if (request != null) request.PipeToClient.Publish(result.DeepClone().SetFinal(false)); if (isRequestCompleted) ProcessCompletedTestRun(test.Test.Run); }