none
Retry pattern in C# RRS feed

  • Question

  • How to use Retry Pattern in the following request.

      private async static Task loginUser()
                {
                bool loginFlag = false,
                     userNameFlag = false,
                     passwordFlag = false;

                string userName, userPassword;

                while (loginFlag != true)
                {
                    Console.WriteLine("enter username");
                    userName = Console.ReadLine();

                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri("http://localhost:12345");
                        client.DefaultRequestHeaders.Accept.Clear();
                        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/..."));
                        HttpResponseMessage response = await client.GetAsync("api/login");

                        if (response.IsSuccessStatusCode)
                            Console.WriteLine("Welcome ");
                    }
                }
            }

    Tuesday, December 3, 2019 8:27 PM

All replies