How do you wait for a Network Stream to have data to read?

后端 未结 3 641
花落未央
花落未央 2021-01-02 07:21

I have a worker thread in my application that is responsible for three different things. Requests for two of the jobs turn up in Queues that I have written, the other job is

3条回答
  •  迷失自我
    2021-01-02 08:02

    I discovered, that if you call NetworkStream.Read with size = 0, it will actually block:

    networkstream.Read(buffer, 0, 0);
    

    The documentation is not clear about this, but for me it worked.

提交回复
热议问题