Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void RunWorkerThread()
- {
- do
- {
- lock (_workerThread)
- {
- if (!_flushNecessary)
- {
- Monitor.Wait(_workerThread, FlushAtAge);
- _flushNecessary = false;
- }
- }
- FlushRequest();
- } while (!_disposed);
- }
- private void FlushRequest()
- {
- lock (_queue)
- {
- _count = 0;
- _strSize = 0;
- _lastFlush = DateTime.Now.Millisecond;
- if (_queue.Count == 0)
- {
- return;
- }
- while (_queue.Count > 0)
- {
- _flushQueue.Add(_queue.Dequeue());
- }
- }
- lock (_targetsLock)
- {
- var count = _autoFlushTargets.Count;
- ILogTarget autoFlushTarget;
- for (var i = 0; i < count; i++)
- {
- autoFlushTarget = _autoFlushTargets[i];
- autoFlushTarget.Log(_flushQueue);
- }
- }
- _flushQueue.Clear();
- }
- #endregion
- /// <summary>
- /// Releases unmanaged and - optionally - managed resources.
- /// </summary>
- public void Dispose()
- {
- LoadingNotifier.Dispose();
- _disposed = true;
- FlushRequest();
- lock (_workerThread)
- {
- Monitor.Pulse(_workerThread);
- }
- var count = _autoFlushTargets.Count;
- for (var i = 0; i < count; i++)
- {
- var target = _autoFlushTargets[i];
- target.Dispose();
- }
- count = _instantTargets.Count;
- for (var i = 0; i < count; i++)
- {
- var target = _instantTargets[i];
- target.Dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement