Esempio n. 1
0
        public void MoveUp()
        {
            Boolean status = true;

            while (status)
            {
                lock (this.Lockobject)
                {
                    if ((DateTime.Now - Starttime).TotalSeconds > Lifetime)
                    {
                        status = false;
                        this.Delete();
                        Mythread.Abort();
                    }
                    this.Delete();
                    this.Y -= this.Speedy;
                    this.X += this.Speedx;

                    if (this.Y <= this.Speedy || this.Y <= 4)
                    {
                        this.Y = Console.WindowHeight - 2;
                    }
                    if (this.X >= Console.WindowWidth - this.Speedx - 3)
                    {
                        this.X = 50;
                    }
                    this.Display();
                    Thread.Sleep(50);
                }
            }
        }
Esempio n. 2
0
 public static void SendSMS(string content, string receiptnos)
 {
     foreach (string receiptno in receiptnos.Split(','))
     {
         if (receiptno != "")
         {
             //System.Threading.Thread.Sleep(2000);
             Mythread MyT = new Mythread();
             MyT.content    = content;
             MyT.receiptnos = receiptno;
             System.Threading.Thread m_WorkerThread = new System.Threading.Thread(new System.Threading.ThreadStart(MyT.WorkdingThread));
             m_WorkerThread.Start();
         }
     }
 }
Esempio n. 3
0
 TcpListener server = null;//创建tcp监听器
 public Server()
 {
     try
     {
         port    = 2018;                                 //端口号
         clients = new List <Socket>();                  //实例化socket list对象
         server  = new TcpListener(IPAddress.Any, port); //设置监听ip和port
         while (true)
         {
             server.Start();                                                //开启服务器
             Socket socket = server.AcceptSocket();                         //死循环监听客户端连接
             clients.Add(socket);                                           //向保存客户端socket list添加socket实例
             Mythread methread = new Mythread(socket, clients.Count - 1);   //实例化Mythread对象,并调用构造函数传送当前socket实例id
             Thread   mythread = new Thread(new ThreadStart(methread.run)); //实例化新线程并采用委托方式
             mythread.Start();                                              //开启一个新线程
         }
     }
     catch (Exception)
     {
     }
 }