private Task DoWork() =>
 ExceptionUtils.DoSwallowingExceptions(_logger, async() =>
 {
     while (true)
     {
         await ProcessQueueItems(await ReceiveBatchAsync());
     }
     // ReSharper disable once FunctionNeverReturns
 }
                                       , dbgCallerMethodName: ThisClassName + "." + DbgUtils.GetCurrentMethodName());
        private void RunOnCurrentThread()
        {
            _logger.Debug()?.Log("`{ThreadName}' thread started", Thread.CurrentThread.Name);

            _isExecuting = true;

            ExceptionUtils.DoSwallowingExceptions(_logger, () =>
            {
                foreach (var task in _taskQueue.GetConsumingEnumerable(_cancellationToken))
                {
                    TryExecuteTask(task);
                }
            }
                                                  , dbgCallerMethodName: $"`{Thread.CurrentThread.Name}' (ManagedThreadId: {Thread.CurrentThread.ManagedThreadId}) thread");

            _isExecuting = false;
        }
Example #3
0
        private async Task WorkLoop()
        {
            _logger.Debug()?.Log("Signaling work loop started event...");
            _loopStarted.Set();

            await ExceptionUtils.DoSwallowingExceptions(_logger, async() =>
            {
                while (true)
                {
                    await WorkLoopIteration();
                }
                // ReSharper disable once FunctionNeverReturns
            }
                                                        , dbgCallerMethodName : ThisClassName + "." + DbgUtils.CurrentMethodName());

            _logger.Debug()?.Log("Signaling work loop completed event...");
            _loopCompleted.Set();
        }
        private async Task WorkLoop()
        {
            _logger.Debug()?.Log("Signaling work loop started event...");
            _loopStarted.Set();

            await ExceptionUtils.DoSwallowingExceptions(_logger, async() =>
            {
                while (!CancellationTokenSource.IsCancellationRequested)
                {
                    await WorkLoopIteration().ConfigureAwait(false);
                }
                // ReSharper disable once FunctionNeverReturns
            }
                                                        , dbgCallerMethodName : _dbgName + "." + DbgUtils.CurrentMethodName())
            .ConfigureAwait(false);

            _logger.Debug()?.Log("Signaling work loop completed event...");
            _loopCompleted.Set();
        }