private void CheckPendingLogsInternal()

in SDK/AppCenter/Microsoft.AppCenter.Windows.Shared/Channel/Channel.cs [576:628]


        private void CheckPendingLogsInternal(State state)
        {
            if (!_enabled)
            {
                AppCenterLog.Info(AppCenterLog.LogTag, "The service has been disabled. Stop processing logs.");
                return;
            }
            if (!_ingestion.IsEnabled)
            {
                AppCenterLog.Info(AppCenterLog.LogTag, "App Center is in offline mode.");
                return;
            }
            AppCenterLog.Debug(AppCenterLog.LogTag, $"CheckPendingLogsInternal({Name}) pending log count: {_pendingLogCount}");
            using (_mutex.GetLock())
            {
                if (_pendingLogCount >= _maxLogsPerBatch)
                {
                    _batchScheduled = true;
                    Task.Run(async () =>
                    {
                        try
                        {
                            await TriggerIngestionAsync(state).ConfigureAwait(false);
                        } 
                        catch (StatefulMutexException)
                        {
                            AppCenterLog.Warn(AppCenterLog.LogTag, "Sending logs operation has been canceled.");
                        }
                    });
                }
                else if (_pendingLogCount > 0 && !_batchScheduled)
                {
                    _batchScheduled = true;

                    // No need wait _batchTimeInterval here.
                    Task.Run(async () =>
                    {
                        await Task.Delay((int)_batchTimeInterval.TotalMilliseconds).ConfigureAwait(false);
                        if (_batchScheduled)
                        {
                            try
                            {
                                await TriggerIngestionAsync(_mutex.State).ConfigureAwait(false);
                            }
                            catch (StatefulMutexException)
                            {
                                AppCenterLog.Warn(AppCenterLog.LogTag, "Sending logs operation has been canceled.");
                            }
                        }
                    });
                }
            }
        }