Esempio n. 1
0
 /// <summary>
 /// Asynchronously counts the number of logs stored for a particular channel
 /// </summary>
 /// <param name="channelName">The name of the channel to count logs for</param>
 /// <returns>The number of logs found in storage</returns>
 /// <exception cref="StorageException"/>
 public Task <int> CountLogsAsync(string channelName)
 {
     return(AddTaskToQueue(() =>
     {
         return _storageAdapter.CountAsync <LogEntry>(entry => entry.Channel == channelName)
         .GetAwaiter().GetResult();
     }));
 }
Esempio n. 2
0
 /// <summary>
 /// Asynchronously counts the number of logs stored for a particular channel
 /// </summary>
 /// <param name="channelName">The name of the channel to count logs for</param>
 /// <returns>The number of logs found in storage</returns>
 /// <exception cref="StorageException"/>
 public async Task <int> CountLogsAsync(string channelName)
 {
     using (await _taskLockSource.GetTaskLockAsync().ConfigureAwait(false))
     {
         return(await _storageAdapter.CountAsync <LogEntry>(entry => entry.Channel == channelName)
                .ConfigureAwait(false));
     }
 }
        /// <summary>
        /// Asynchronously counts the number of logs stored for a particular channel
        /// </summary>
        /// <param name="channelName">The name of the channel to count logs for</param>
        /// <returns>The number of logs found in storage</returns>
        /// <exception cref="StorageException"/>
        public async Task <int> CountLogsAsync(string channelName)
        {
            var task = new Task <int>(() =>
            {
                return(_storageAdapter.CountAsync <LogEntry>(entry => entry.Channel == channelName)
                       .Result);
            });

            try
            {
                _queue.Add(task);
            }
            catch (InvalidOperationException)
            {
                throw new StorageException("The operation has been cancelled");
            }
            _flushSemaphore.Release();
            return(await task.ConfigureAwait(false));
        }