protected virtual void Dispose(bool disposing) { if (!isDisposed) { isDisposed = true; if (disposing) { tickQueue.Terminate(); } } }
protected virtual void Dispose(bool disposing) { if (!isDisposed) { lock ( taskLocker) { isDisposed = true; if (disposing) { if (task != null) { task.Stop(); task.Join(); tickQueue.Terminate(); } } task = null; // Leave tickQueue set so any extraneous // events will see the queue is already terminated. // tickQueue = null; } } }
public bool OnError(string error) { log.Error(error); tickQueue.Terminate(); return(true); }
protected virtual Yield AppendData() { try { if (writeQueue.Count == 0) { return(Yield.NoWork.Repeat); } if (!keepFileOpen) { fs = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.Read); if (trace) { log.Trace("!keepFileOpen - Open()"); } memory = new MemoryStream(); } while (writeQueue.TryDequeue(ref tick)) { tickIO.Inject(tick); if (trace) { log.Trace("Writing to file: " + tickIO); } WriteToFile(memory, tickIO); } if (!keepFileOpen) { fs.Close(); if (trace) { log.Trace("!keepFileOpen - Close()"); } fs = null; } return(Yield.DidWork.Repeat); } catch (QueueException ex) { if (ex.EntryType == EventType.Terminate) { log.Debug("Exiting, queue terminated."); if (fs != null) { fs.Close(); log.Debug("Terminate - Close()"); } return(Yield.Terminate); } else { Exception exception = new ApplicationException("Queue returned unexpected: " + ex.EntryType); writeQueue.Terminate(exception); throw ex; } } catch (Exception ex) { writeQueue.Terminate(ex); if (fs != null) { fs.Close(); } throw; } }
public void OnError(string error) { log.Error(error); tickQueue.Terminate(); }