HttpClient with infinite time out throws time out exception

后端 未结 3 1309
被撕碎了的回忆
被撕碎了的回忆 2021-02-15 18:13

My HttpClient uses digest authentication to connect to the server and expects search queries in response. These search queries can come in any time so the client is expected to

3条回答
  •  梦如初夏
    2021-02-15 19:02

    Make the method return a Task

    public static async Task ListenForSearchQueries(int resourceId) {
        //...code removed for brevity
    }
    

    Update the console's main method to Wait on the Task to complete.

    public static void Main(string[] args) {
       const int serviceId = 128;
       .
       .
       .
       ListenForSearchQueries(resourceId).Wait();
       Console.ReadKey();
    }
    

提交回复
热议问题