DataAnalysis.cs,监听线程的代码
public static Thread consoleThread;
public static void StartAnalysis(){
consoleThread=new Thread(TCPClient.ReceiveTCPMsg);
consoleThread.isBackground=true;
consoleThread.Start(Globel.socket);
}
DetectLinkStatus.cs,监听连接状态线程的部分代码
if(Globel.socket.Poll(100000,SelectMode.SelectRead)){
SocketInit();//建立新的socket连接,更新Globel.socket
DataAnalysis.consoleThread.Abort();//结束之前的监听线程
DataAnalysis.consoleThread=null;
//启动新的监听线程
DataAnalysis.consoleThread=new Thread(TCPClient.ReceiveTCPMsg);
DataAnalysis.consoleThread.isBackground=true;
DataAnalysis.consoleThread.Start(Globel.socket);
}
但是在这里一直抛异常
引发的异常:“System.Threading.ThreadAbortException”,
,但是功能已经实现了,就是后台抛异常。
这异常是不是因为在线程中关闭了线程?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
原来如此懂了