/// <summary>
 /// Method that is called to signal start of the Push service.
 /// </summary>
 /// <param name="channelGroup"></param>
 /// <param name="appSecret"></param>
 public override void OnChannelGroupReady(IChannelGroup channelGroup, string appSecret)
 {
     using (_mutex.GetLock())
     {
         base.OnChannelGroupReady(channelGroup, appSecret);
         ApplyEnabledState(IsEnabledAsync().Result);
     }
 }
Esempio n. 2
0
        internal Channel(string name, int maxLogsPerBatch, TimeSpan batchTimeInterval, int maxParallelBatches,
                         string appSecret, IIngestion ingestion, IStorage storage)
        {
            Name = name;
            _maxParallelBatches = maxParallelBatches;
            _maxLogsPerBatch    = maxLogsPerBatch;
            _appSecret          = appSecret;
            _ingestion          = ingestion;
            _storage            = storage;
            _batchTimeInterval  = batchTimeInterval;
            _batchScheduled     = false;
            _enabled            = true;
            DeviceInformationHelper.InformationInvalidated += (sender, e) => InvalidateDeviceCache();
            var lockHolder = _mutex.GetLock();

            Task.Run(() => _storage.CountLogsAsync(Name)).ContinueWith(task =>
            {
                if (!task.IsFaulted && !task.IsCanceled)
                {
                    _pendingLogCount = task.Result;
                }
                lockHolder.Dispose();
            });
        }