C# Stream.Read with timeout

后端 未结 2 1851
别跟我提以往
别跟我提以往 2020-12-03 17:33

I have this streamreader:

            Boolean read = false;
            while (wline!=\"exit\")
            {

                while (!read || streamReader.P         


        
2条回答
  •  不思量自难忘°
    2020-12-03 17:48

    If this is System.IO.StreamReader, then set it on the BaseStream:

    streamReader.BaseStream.ReadTimeout = 2000;  //milliseconds, so 2 seconds
    

提交回复
热议问题