zoukankan      html  css  js  c++  java
  • 线程启动带参数

    public void StartThread() 
            {
                Thread TempThread = new Thread(new ThreadStart(Start));
                TempThread.Start();
            }

    带参数的:

    public void StartThread() 
            {
                Thread TempThread = new Thread(new ParameterizedThreadStart(Start));
                TempThread.Start();
            }
    
            public void Start(object ip) 
            {
                server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                bool isGo = true;
                server.Bind(new IPEndPoint(IPAddress.Parse(ip.ToString()), 3001));
                server.Listen(10);
                while (isGo) 
                {
                    try
                    {
                        Socket s = server.Accept();
                        string content = "";
                        byte[] bytes = new byte[s.Available];
                        int num = s.Receive(bytes, 0, bytes.Length, SocketFlags.None);
    
                        content = Encoding.ASCII.GetString(bytes);
    
                        if (content.Equals("conn")) 
                        {
                            s.Send(Encoding.ASCII.GetBytes("connstr"));
                        }
                        if (content.Equals("Close")) 
                        {
                            isGo = false;
                        }
    
                        s.Close();
                        s.Dispose();
                    }
                    catch (Exception ex)
                    {
                        
                    }
                }
    
                server.Close();
                server.Dispose();
            }
  • 相关阅读:
    闭包的应用(转载)
    智能社讲解js基础
    HTML5 Geolocation
    Redis主从配置
    Redis序列化配置
    Ribbon负载均衡原理学习记录
    2059 mysql
    Cache缓存
    rabbitmq(三)-Direct交换器
    rabbitmq(二)原理
  • 原文地址:https://www.cnblogs.com/wpcnblog/p/3912096.html
Copyright © 2011-2022 走看看