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 = 새 스레드 (InboxTCPServer ("127.0.0.1", 1001)); t.Start();' – misleadingTitle