public void CloseBackupFile(string name, RecoveryFileState state) { //M_TODO: // Add timeout interval for file writing, incase the data is not being consumed and timeout span has been reached, break the loop and DIE!!! try { // TimeSpan timeSpan BackupFile file = _activeContext.GetBackupFile(name); file.FileHeader.State = state; int elapsed = 0; // if file not already flushed if (!file.HeaderFlushed) { while (!_activeContext.SharedQueue.Consumed) { // wait till all data has been consumed and written } if (_activeContext.SharedQueue.Consumed) { if (file.SaveHeader()) { if (LoggerManager.Instance.RecoveryLogger != null && LoggerManager.Instance.RecoveryLogger.IsInfoEnabled) { LoggerManager.Instance.RecoveryLogger.Info("RecoveryPersistenceManager.CloseBackupFile()", file.Name + " closing"); } file.Close(); } else { throw new Exception("Unable to write data"); } } } } catch (Exception exp) { if (LoggerManager.Instance.RecoveryLogger != null && LoggerManager.Instance.RecoveryLogger.IsErrorEnabled) { LoggerManager.Instance.RecoveryLogger.Error("RecoveryPersistenceManager.CloseBackupFile()", exp.ToString()); } } }