Beispiel #1
0
        /// <summary>
        /// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
        /// </summary>
        /// <returns></returns>
        public static MyTcpServer GetInstance()
        {
            if (m_UniqueTcpServer == null)
            {
                lock (m_Locker)
                {
                    if (m_UniqueTcpServer == null)
                    {
                        m_UniqueTcpServer = new MyTcpServer();
                    }
                }
            }

            return(m_UniqueTcpServer);
        }
Beispiel #2
0
        private void BtnCreateServer_Click(object sender, EventArgs e)
        {
            m_MyTcpServerArm = MyTcpServer.GetInstance();
            if (m_MyTcpServerArm != null)
            {
                IPAddress ServerIp   = IPAddress.Parse(TextBoxIp.Text);
                int       ServerPort = int.Parse(TextBoxPort.Text);
                m_MyTcpServerArm.CreatServer(ServerIp, ServerPort);
            }

            m_OutStream = File.Open(m_UpdateFileName, FileMode.OpenOrCreate);
            m_Writer    = new BinaryWriter(m_OutStream);

            //创建升级线程
            m_MainThread = new Thread(new ThreadStart(MainThreadFunc));
            m_MainThread.IsBackground = true;
            m_MainThread.Start();
        }