Esempio n. 1
0
        private void OnRequestComplete()
        {
            if (CancellationTokenSource.IsCancellationRequested)
            {
                return;
            }
            RequestTask task = Tasks.Last(x => x.Response.IsCompleted);

            if (task.Response.IsCanceled)
            {
                CliNotifier.PrinWarning("Cannot load response");
            }
            else if (task.Response.IsFaulted)
            {
                CliNotifier.PrinWarning("Server cancel connection");
            }
            else
            {
                task.EndedAt = DateTime.Now.TimeOfDay;
                CliNotifier.PrintInfo($"Request finished by: {task.TotalExecutionTime} with status code: { task.Response.Result.StatusCode}");
                Completed.Add(task);
                if (IsStopSignal(task.Response.Result))
                {
                    StopExecution();
                }
            }
            RuningTasks--;
            if (RuningTasks < ConfigParser.GetParallel())
            {
                AddTask();
            }
        }