public async Task ShutdownAsync() { ThrowIfDisposed(); var tasks = new List <Task>(); lock (_channelGroupLock) { if (_isShutdown) { AppCenterLog.Warn(AppCenterLog.LogTag, "Attempted to shutdown channel multiple times."); return; } _isShutdown = true; _ingestion.Close(); foreach (var channel in _channels) { tasks.Add(channel.ShutdownAsync()); } } await Task.WhenAll(tasks).ConfigureAwait(false); AppCenterLog.Debug(AppCenterLog.LogTag, "Waiting for storage to finish operations."); if (!await _storage.ShutdownAsync(WaitStorageTimeout).ConfigureAwait(false)) { AppCenterLog.Warn(AppCenterLog.LogTag, "Storage taking too long to finish operations; shutting down channel without waiting any longer."); } }
private void Suspend(State state, bool deleteLogs, Exception exception) { try { IEnumerable <Log> unsentLogs = null; using (_mutex.GetLock(state)) { _enabled = false; _batchScheduled = false; _discardLogs = deleteLogs; if (deleteLogs) { unsentLogs = _sendingBatches.Values.SelectMany(batch => batch); _sendingBatches.Clear(); } state = _mutex.InvalidateState(); } if (unsentLogs != null) { foreach (var log in unsentLogs) { FailedToSendLog?.Invoke(this, new FailedToSendLogEventArgs(log, exception)); } } if (deleteLogs) { try { _ingestion.Close(); } catch (IngestionException e) { AppCenterLog.Error(AppCenterLog.LogTag, "Failed to close ingestion", e); } using (_mutex.GetLock(state)) { _pendingLogCount = 0; TriggerDeleteLogsOnSuspending(); } } _storage.ClearPendingLogState(Name); } catch (StatefulMutexException) { AppCenterLog.Warn(AppCenterLog.LogTag, "The Suspend operation has been cancelled"); } }
private Task Suspend(bool deleteLogs, Exception exception) { _enabled = false; _batchScheduled = false; _discardLogs = deleteLogs; _stateKeeper.InvalidateState(); var stateSnapshot = _stateKeeper.GetStateSnapshot(); try { if (deleteLogs && FailedToSendLog != null) { foreach (var log in _sendingBatches.Values.SelectMany(batch => batch)) { _mutex.Unlock(); FailedToSendLog?.Invoke(this, new FailedToSendLogEventArgs(log, exception)); _mutex.Lock(stateSnapshot); } } try { _ingestion.Close(); } catch (IngestionException e) { MobileCenterLog.Error(MobileCenterLog.LogTag, "Failed to close ingestion", e); } if (deleteLogs) { _pendingLogCount = 0; return(Task.Run(DeleteLogsOnSuspendedAsync)); } return(_storage.ClearPendingLogStateAsync(Name)); } catch (StatefulMutexException e) { MobileCenterLog.Warn(MobileCenterLog.LogTag, "The CountFromDisk operation has been cancelled", e); return(null); } }
public virtual void Close() { DecoratedApi.Close(); }