コード例 #1
0
 public void AcceptClients()
 {
     while (true)
     {
         var client = MasterServer.AcceptTcpClient();
         if (client.Connected)
         {
             Task.Factory.StartNew(() =>
             {
                 var ch = new ConnectionHandler(client, this);
                 ch.HandleConnection();
             });
             ConnectClients.Add(client);
             Console.WriteLine("Client added and is now awaiting work: " + client.GetHashCode());
         }
     }
 }
コード例 #2
0
 private void AcceptClients()
 {
     while (!IsDone())
     {
         try
         {
             var client = MasterServer.AcceptTcpClient();
             if (client.Connected)
             {
                 var ch = new ConnectionHandler(client, this);
                 Task.Factory.StartNew(() =>
                 {
                     ch.HandleConnection();
                 });
                 ConnectClients.Add(ch);
                 Console.WriteLine("Client added and is now awaiting work: " + client.GetHashCode());
             }
         }
         catch (Exception)
         {
             Console.WriteLine("Reached the end of dictionary");
         }
     }
 }