Exemplo n.º 1
0
    public static Task OnUpdatePostTaskAsync(this TelegramService telegramService)
    {
        var op = Operation.Begin("Run PostTask");

        var nonAwaitTasks = new List <Task>
        {
            telegramService.EnsureChatSettingsAsync(),
            telegramService.AfkCheckAsync(),
            telegramService.CheckNameChangesAsync(),
            telegramService.EnsureForceSubscriptionAsync(),
            telegramService.EnsureChatAdminAsync(),
            telegramService.EnsureReplyNotificationAsync(),
            telegramService.BotSlowdownNotification(),
            telegramService.RunSpellingAsync(),
            telegramService.SaveUpdateAsync(),
            telegramService.WarningCompressImageWhenPossibleAsync()
        };

        nonAwaitTasks.InBackgroundAll();

        op.Complete();

        return(Task.CompletedTask);
    }
        private void EnqueueBackgroundTask()
        {
            var nonAwaitTasks = new List <Task>();
            var message       = _telegramService.MessageOrEdited;

            //Exec nonAwait Tasks
            Log.Information("Running nonAwait task..");
            nonAwaitTasks.Add(_telegramService.EnsureChatHealthAsync());
            nonAwaitTasks.Add(_telegramService.AfkCheckAsync());

            if (message.Text != null)
            {
                nonAwaitTasks.Add(_telegramService.FindNotesAsync());
                nonAwaitTasks.Add(_telegramService.FindTagsAsync());
            }

            nonAwaitTasks.Add(_telegramService.CheckMataZiziAsync());
            nonAwaitTasks.Add(_telegramService.HitActivityAsync());

#pragma warning disable 4014
            // This List Task should not await.
            Task.WhenAny(nonAwaitTasks.ToArray());
#pragma warning restore 4014
        }