private async Task EnqueuePreTask() { Log.Information("Enqueue pre tasks"); var message = _telegramService.MessageOrEdited; var callbackQuery = _telegramService.CallbackQuery; // var actions = new List<Action>(); var shouldAwaitTasks = new List <Task>(); if (!_telegramService.IsPrivateChat()) { shouldAwaitTasks.Add(_telegramService.EnsureChatRestrictionAsync()); if (message.Text != null) { shouldAwaitTasks.Add(_telegramService.CheckGlobalBanAsync()); shouldAwaitTasks.Add(_telegramService.CheckCasBanAsync()); shouldAwaitTasks.Add(_telegramService.CheckSpamWatchAsync()); shouldAwaitTasks.Add(_telegramService.CheckUsernameAsync()); } } if (callbackQuery == null) { shouldAwaitTasks.Add(_telegramService.CheckMessageAsync()); } Log.Information("Awaiting should await task.."); await Task.WhenAll(shouldAwaitTasks.ToArray()) .ConfigureAwait(false); }