moved wait to finally block
This commit is contained in:
@@ -319,9 +319,13 @@ namespace TimberWinR.Outputs
|
|||||||
_batchCounter.SampleQueueDepth(_jsonQueue.Count);
|
_batchCounter.SampleQueueDepth(_jsonQueue.Count);
|
||||||
// Re-compute current batch size
|
// Re-compute current batch size
|
||||||
|
|
||||||
LogManager.GetCurrentClassLogger().Trace("{0}: Average Queue Depth: {1}, Current Length: {2}", Thread.CurrentThread.ManagedThreadId, _batchCounter.AverageQueueDepth(), _jsonQueue.Count);
|
LogManager.GetCurrentClassLogger()
|
||||||
|
.Trace("{0}: Average Queue Depth: {1}, Current Length: {2}",
|
||||||
_currentBatchCount = _batchCounter.UpdateCurrentBatchCount(_jsonQueue.Count, _currentBatchCount);
|
Thread.CurrentThread.ManagedThreadId, _batchCounter.AverageQueueDepth(),
|
||||||
|
_jsonQueue.Count);
|
||||||
|
|
||||||
|
_currentBatchCount = _batchCounter.UpdateCurrentBatchCount(_jsonQueue.Count,
|
||||||
|
_currentBatchCount);
|
||||||
|
|
||||||
messages = _jsonQueue.Take(_currentBatchCount).ToArray();
|
messages = _jsonQueue.Take(_currentBatchCount).ToArray();
|
||||||
_jsonQueue.RemoveRange(0, messages.Length);
|
_jsonQueue.RemoveRange(0, messages.Length);
|
||||||
@@ -342,7 +346,9 @@ namespace TimberWinR.Outputs
|
|||||||
{
|
{
|
||||||
client.StartPipe();
|
client.StartPipe();
|
||||||
LogManager.GetCurrentClassLogger()
|
LogManager.GetCurrentClassLogger()
|
||||||
.Debug("{0}: Sending {1} Messages to {2}", Thread.CurrentThread.ManagedThreadId, messages.Length, client.Host);
|
.Debug("{0}: Sending {1} Messages to {2}",
|
||||||
|
Thread.CurrentThread.ManagedThreadId, messages.Length,
|
||||||
|
client.Host);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -394,9 +400,7 @@ namespace TimberWinR.Outputs
|
|||||||
_jsonQueue.InsertRange(0, messages);
|
_jsonQueue.InsertRange(0, messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!Stop)
|
|
||||||
syncHandle.Wait(TimeSpan.FromMilliseconds(_interval), CancelToken);
|
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (OperationCanceledException)
|
||||||
{
|
{
|
||||||
@@ -412,6 +416,17 @@ namespace TimberWinR.Outputs
|
|||||||
Interlocked.Increment(ref _errorCount);
|
Interlocked.Increment(ref _errorCount);
|
||||||
LogManager.GetCurrentClassLogger().Error(ex);
|
LogManager.GetCurrentClassLogger().Error(ex);
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Stop)
|
||||||
|
syncHandle.Wait(TimeSpan.FromMilliseconds(_interval), CancelToken);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user