/// <summary> /// Start the process. /// </summary> public void Start() { try { string xmlValidationMessage = string.Empty; // Get the xml file location and // the xsd file schema. string xml = Nequeo.Maintenance.Properties.Settings.Default.LogFileListXmlPath; string xsd = Nequeo.Maintenance.Properties.Resources.LogFileList; // Validate the filter xml file. if (!Validation.IsXmlValidEx(xsd, xml, out xmlValidationMessage)) { throw new Exception("Xml validation. " + xmlValidationMessage); } // Deserialise the xml file into // the log directory list object GeneralSerialisation serial = new GeneralSerialisation(); LogDirectoryList directoryList = ((LogDirectoryList)serial.Deserialise(typeof(LogDirectoryList), xml)); // Start the deletion process. _timer = new IntervalControl(directoryList.Interval); _timer.Start(u => DeleteLogFiles(u), directoryList); } catch (Exception e) { // Detect a thread abort exception. if (e is ThreadAbortException) { Thread.ResetAbort(); } } }
/// <summary> /// Dispose(bool disposing) executes in two distinct scenarios. /// If disposing equals true, the method has been called directly /// or indirectly by a user's code. Managed and unmanaged resources /// can be disposed. /// If disposing equals false, the method has been called by the /// runtime from inside the finalizer and you should not reference /// other objects. Only unmanaged resources can be disposed. /// </summary> protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this._disposed) { // Note disposing has been done. _disposed = true; // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { if (_timer != null) { _timer.Dispose(); } } // Call the appropriate methods to clean up // unmanaged resources here. _timer = null; } }