About streamreader

tongjin9 2003-01-28 10:13:01
Dear all,
In my c# program,I have define a thread,the method is:

public static void ReadResponseThread()
{
StreamReader sr = new StreamReader(ss, System.Text.Encoding.ASCII);
//ss is a class instance,defined as:public class SerialStream : Stream
//{...} SerialStream is a class to operate com port
// static SerialStream ss;
try {
// Read response from com
string response = sr.ReadLine();
Console.WriteLine("Response: " + response);
}
catch (ThreadAbortException)
{}
}

I use it like this:
Thread responseReaderThread = new Thread(new ThreadStart (ReadResponseThread));
responseReaderThread.Start();
But program will stop(not dead,not the style of breakpoint) at line:string response=sr.ReadLine(),and no error.
Of course,I can not receive any data form com port.
What can i do?
...全文
143 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧