private void RunUserRequest(object args) { var requestId = "N/A"; try { var userRequest = (UserRequestWrapper)args; requestId = userRequest.Id; try { // Heart of the process userRequest.Statement // 1. Take a statement .ToWordArray(userRequest.RemovePunctuation) // 2. Split into words with/without removal of punctuation .CountWordOccurences() //3. Transform into word-counter pairs .ToList() .ForEach( countedWord => // and add each one to dictionary { userRequest.Snapshot = SharedDictionary.CheckIncrement(countedWord.Word, countedWord.Count); }); } catch (Exception ex) { _logger.Error(string.Format("Error processing request id {0}: {1}", requestId, ex.ToString())); userRequest.HasError = true; userRequest.Error = ex.ToString(); } finally { RemoveUserRequest(requestId); try { _servedUserRequests.Release(); } catch { } userRequest.WaitForRequestToComplete.Set(); userRequest.RequestCompleteAt = DateTime.Now; } } catch (Exception ex) { _logger.Error(string.Format("Error processing request id {0}: {1}", requestId, ex.ToString())); } }