in SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Channel/Channel.cs [312:364]
private void Suspend(State state, bool deleteLogs, Exception exception, bool needDisableChannel = true)
{
AppCenterLog.Debug(AppCenterLog.LogTag, $"Suspend channel: '{Name}'");
try
{
IList<string> sendingBatches = null;
IList<Log> unsentLogs = null;
using (_mutex.GetLock(state))
{
if (needDisableChannel)
{
_enabled = false;
}
_batchScheduled = false;
_discardLogs = deleteLogs;
if (deleteLogs)
{
sendingBatches = _sendingBatches.Keys.ToList();
unsentLogs = _sendingBatches.Values.SelectMany(batch => batch).ToList();
_sendingBatches.Clear();
}
state = _mutex.InvalidateState();
}
if (unsentLogs != null && FailedToSendLog != null)
{
foreach (var log in unsentLogs)
{
AppCenterLog.Debug(AppCenterLog.LogTag, $"Invoke FailedToSendLog event for channel '{Name}'");
FailedToSendLog?.Invoke(this, new FailedToSendLogEventArgs(log, exception));
}
}
if (deleteLogs)
{
IList<IServiceCall> calls;
using (_mutex.GetLock(state))
{
calls = _calls.ToList();
_calls.Clear();
_pendingLogCount = 0;
TriggerDeleteLogsOnSuspending(sendingBatches);
}
foreach (var call in calls)
{
call.Cancel();
}
}
_storage.ClearPendingLogState(Name);
}
catch (StatefulMutexException)
{
AppCenterLog.Warn(AppCenterLog.LogTag, "The suspend operation has been canceled");
}
}