private static void ReceiveMessage(object clientSocket)
        {
            Socket myClientSocket = (Socket)clientSocket;

            try
            {
                int receiveNumber = myClientSocket.Receive(result);
                Console.WriteLine("启动监听{0}成功", myClientSocket.RemoteEndPoint.ToString());

                receiveAppnamesStrs = System.Text.Encoding.UTF8.GetString(result, 0, receiveNumber);
                Console.WriteLine("请求安装:{0}", receiveAppnamesStrs);

                //安装用户要求的应用
                try
                {
                    if (receiveAppnamesStrs != null)
                    {
                        installRequiredApp(receiveAppnamesStrs, myClientSocket);
                    }
                }
                catch (Exception e)
                {
                    myClientSocket.Send(Encoding.UTF8.GetBytes("error!!!error1\n"));
                    Console.WriteLine("安装异常+:{0}", e.Message);
                    ConsoleWin32Helper.HideNotifyIcon();
                    System.Environment.Exit(0);
                }
            }
            catch (Exception e)
            {
                myClientSocket.Send(Encoding.UTF8.GetBytes("error!!!error2\n"));
                Console.WriteLine("接收确认、安装异常++:{0}", e.Message);
                ConsoleWin32Helper.HideNotifyIcon();
                System.Environment.Exit(0);
            }
            finally
            {
                try
                {
                    if (myClientSocket != null)
                    {
                        myClientSocket.Close();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("socket异常{0}", e.Message);
                    ConsoleWin32Helper.HideNotifyIcon();
                    System.Environment.Exit(0);
                }
            }
        }
        static void Main()
        {
            if (PortInUse(12123))
            {
                MessageBox.Show("AppAutoInstall已经打开或者12123端口被占用");
            }
            else
            {
                ConsoleWin32Helper.ShowNotifyIcon();  //显示系统托盘

                IPAddress ip = IPAddress.Parse("0.0.0.0");
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                serverSocket.Bind(new IPEndPoint(ip, myPort));
                serverSocket.Listen(10);
                Console.WriteLine("启动监听{0}成功", serverSocket.LocalEndPoint.ToString());
                Thread myThread = new Thread(ListenClientConnect);
                myThread.Start();

                while (true)
                {
                    Application.DoEvents();  //用Application.DoEvents()来捕获消息事件处理,但是要用死循环来控制
                }
            }
        }