public override WaitHandle DoWork()
{
var failOccurrences = FailQueue.Dequeue(ConfigurationModel.Instance.ReportingMinimumBatchSize);
if (failOccurrences.Count() > 0)
{
var failSubmission = new FailSubmissionDto(ConfigurationModel.Instance.ApiToken, failOccurrences);
if (!PostToService(failSubmission))
{
// Submission fails, so add these back to the reporting queue
foreach (var occurrence in failOccurrences)
{
occurrence.IncrementSubmissionAttempts();
if (occurrence.SubmissionAttempts < ConfigurationModel.Instance.ReportingSubmissionAttempts)
{
FailQueue.Enqueue(occurrence);
}
}
}
}
// Return the wait handle that will signal to
// call this worker method when the queue is not empty.
return FailQueue.WaitHandle;
}