Пример #1
0
        private async void MainLoop()
        {
            while (true)
            {
                await Task.Delay(1000).ConfigureAwait(true);;

                try
                {
                    if (!_launched)
                    {
                        await CreateAndActivate().ConfigureAwait(false);

                        _launched = true;
                    }

                    await UpdateTask().ConfigureAwait(false);

                    AnswerTaskQuestions();
                    await SubmitTaskResults().ConfigureAwait(false);

                    _tasksRepository.ReplaceTask();
                }
                catch (ApiException apiExceptionx)
                {
                    Console.WriteLine(apiExceptionx.Content.Trim());
                    break;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    break;
                }
                finally
                {
                    await SaveState().ConfigureAwait(false);
                }
            }
        }