OpenWinnyについて

このエントリーをはてなブックマークに追加
298[名無し]さん(bin+cue).rar
激重の原因はここじゃないか?
m_listener.Pending() が false の間、無駄にループしてCPUを食いつぶす。

private void ListenStart() {
  m_listener = new TcpListener(IPAddress.Any, ManageNode.MyNodeInfo.Port);
  m_listener.Start();
  int threadmaxnum = 10;
  Thread[] threads = new Thread[threadmaxnum];
  Thread[] timerthreads = new Thread[threadmaxnum];
  while (true) {
    try {
      for (int i = 0; i < threads.Length; i++) {
        if (m_listener.Pending() == true) {
          TcpClient client = m_listener.AcceptTcpClient();
          bool flag = false;
          if (threads[i] == null || threads[i].IsAlive == false) {
            ProcessClient procclient = new ProcessClient(client);
            threads[i] = new Thread(new ThreadStart(procclient.Process));
            threads[i].Start();
            (略)
          }
        }
      }
    } catch (Exception) {
      break;
    }
  }
}