private void btnOK_Click(object sender, EventArgs e) { sUrl = sUrlHead; //CallInformationFromServer(); try { //获取ID // GetIdForCallFunction(); CsConst.MyQuene = new Queue <byte[]>(); CsConst.MyBlnCapture = true; if (thread == null) { thread = new Thread(CrossThreadFlush); thread.IsBackground = true; thread.Start(); } HDLUDP.GetRightIPAndPort(); CsConst.mySends.IniTheSocket(CsConst.myLocalIP); timerCall.Enabled = false; #region //if (threadDisplayMessages == null) //{ // threadDisplayMessages = new Thread(ThreadHttpFunction); // threadDisplayMessages.IsBackground = true; // threadDisplayMessages.Start(); //} //if (threadHttp == null) //{ // socketwatch = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // //服务端发送信息需要一个IP地址和端口号 // IPAddress address = IPAddress.Parse(CsConst.myLocalIP); // //将IP地址和端口号绑定到网络节点point上 // IPEndPoint point = new IPEndPoint(address, 88); // //此端口专门用来监听的 // //监听绑定的网络节点 // socketwatch.Bind(point); // //将套接字的监听队列长度限制为20 // socketwatch.Listen(20); // //负责监听客户端的线程:创建一个监听线程 // Thread threadwatch = new Thread(WaitReceiveHttpPostInformation); // //将窗体线程设置为与后台同步,随着主线程结束而结束 // threadwatch.IsBackground = true; // //启动线程 // threadwatch.Start(); //} #endregion } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void frmMain_Load(object sender, EventArgs e) { Control.CheckForIllegalCrossThreadCalls = false; CsConst.mstrINIDefault = new IniFile(System.Windows.Forms.Application.StartupPath + @"\ini\Default.ini"); CsConst.myLocalIP = GetLocalIP(); HDLUDP.GetRightIPAndPort(); DisplayBasicInformation(); DislayLockInformationWhenFirstLoad(); timerCall = new System.Timers.Timer(); timerCall.Interval = 5000 * 1; timerCall.Elapsed += new System.Timers.ElapsedEventHandler(timerCall_Elapsed); bIsWaitingFeedback = false; }