Esempio n. 1
0
 private void AddToExecutionResults(HttpActionResult result)
 {
     resultsLock.EnterWriteLock();
     this.executionResults.Add(result);
     resultsLock.ExitWriteLock();
 }
Esempio n. 2
0
 private async Task<HttpActionResult> ExecuteAction(HttpClient httpClient, HttpRequestMessage step)
 {
     HttpActionResult result = null;
     HttpResponseMessage response = null;            
     Stopwatch watch = new Stopwatch();
     var isTimeout = false;
     try 
     {                
         watch.Start();
         response = await httpClient.SendAsync(step, HttpCompletionOption.ResponseContentRead);                
         watch.Stop();
                         
     }
     catch (TaskCanceledException ex)
     {
         watch.Stop();
         isTimeout = true;                
         response = null;
     }
     finally 
     {
         this.statsLock.EnterWriteLock();
         this.hits++;
         if (response != null && !response.IsSuccessStatusCode)
         {
             this.errors++;
         }
         if (isTimeout)
         {
             this.timeouts++;
         }
         this.statsLock.ExitWriteLock();
         result = new HttpActionResult()
         {
             RequestTimedOut = isTimeout,
             ResponseMessage = response,
             ResponseTime = watch.ElapsedMilliseconds,
             ConcurrentUsers = this.ReadConcurrentUsersCounter()
         };
     }
     
     return result;
 }