0
我开发一个应用程序,而开发中我得到一个问题。所以我想解决它。我正在使用TCP服务器和客户端概念。我写的代码很好。但阻止我的WPF窗口。我该如何解决它?谁能帮我。TCP连接阻止我的WPF窗口?如何获取WPF窗口?
我的代码
private void LoadingInboxMessage(){
try {
InboxTCPServer("127.0.0.1",1001);
string []header = new string[]{"Name","Mobile","Address"};
SQL sql = new SQL();
MySqlConnection con = sql.ConnectServer("127.0.0.1","root","''","smsdb");
if(con!=null) {
MySqlDataReader dr = sql.SQLFetching(con,"SELECT * FROM receivedetails");
CreateFlowDocument cfd = new CreateFlowDocument("inboxFlow");
this.InboxFlowDocument.Document = cfd.CreateTable("inboxtable",header,dr);
}
else {
MessageBox.Show("Not Connectioned");
Application.Current.Shutdown(0);
}
} catch(Exception e) {
MessageBox.Show(e.Message);
}
}
public void InboxTCPServer(string ipv4, int port){
try {
IPAddress ip = IPAddress.Parse(ipv4);
TcpListener serv = new TcpListener(ip,port);
serv.Start();
Socket s = serv.AcceptSocket();
byte[] b = new byte[1000];
int k = s.Receive(b);
MessageBox.Show(b.ToString());
} catch(Exception e) {
MessageBox.Show(e.Message);
}
}
请 “救救我”
它不工作的哥哥! :(任何其他的解决方案 – Kernel
你是怎样在你的代码中实现它 的其他简单的解决办法可能是从改变: 'InboxTCPServer(“127.0.0.1”,1001);' 到:?? '线程t = new Thread(InboxTCPServer(“127.0.0.1”,1001)); t.Start();' – misleadingTitle