Example #1
0
 /// <summary>
 /// 开始读取数据
 /// </summary>
 public void Start()
 {
     try
     {
         Client.stream.BeginRead(Client.data, 0, 1, onStatus, this);
     }
     catch (Exception error)
     {
         log.Default.Add(error, null, false);
         Client.Dispose();
         OnRead(null);
     }
 }
Example #2
0
 /// <summary>
 /// 释放TCP调用客户端
 /// </summary>
 /// <param name="client">TCP调用客户端</param>
 protected void saveClient(fastCSharp.net.tcpClient client)
 {
     if (client != null)
     {
         bool isSave = false;
         Monitor.Enter(clientLock);
         try
         {
             --currentCount;
             if (!isStop && client.IsStart)
             {
                 isSave = true;
                 clients.Add(client);
             }
         }
         finally { Monitor.Exit(clientLock); }
         if (isSave)
         {
             pulseWait();
         }
         else if (client.IsStart)
         {
             client.Dispose();
         }
     }
 }