title: SSH.NET Session Timeout on multithread
body: <p>I have the below for a multi-threaded FTP process. The MaxThread is 4 as our destination client has capped us at 4 threads.             </p>
  
  <pre><code>ThreadPool.SetMaxThreads(workerThreads, completionPortThreads);
  
          foreach (var loan in fileList)
          {
              // Create an MRE for each thread.
              var handle = new ManualResetEvent(false);
  
              // Store it for use below.
              handles.Add(handle);
              ThreadPool.QueueUserWorkItem(FtpProcess, Tuple.Create(loan, handle));
          }
          // Wait for threads to finish.
          WaitHandle.WaitAll(handles.ToArray());
  </code></pre>
  
  <p>Inside FtpProcess method the connection is created and the QueueUserWorkItem waits for an open thread to continue. But the connection will not occur. I receive a Session Timeout error in this.</p>
  
  <pre><code>private static void FtpProcess(object loanObject)
  {
      var tuple = (Tuple&lt;KeyValuePair&lt;string, List&lt;string&gt;&gt;, ManualResetEvent&gt;)loanObject;
      var loan = tuple.Item1;
      var client = new SftpClient(removed for security but this is filled in);
  
      if (!client.IsConnected)
      {
         client.Connect();
      }
  </code></pre>
  
  <p>Now, if I don't use the QueueUserWorkItem and just use new Thread(FtpProcess).Start then it works and connects multiple times until the cap issue takes place.</p>
  
  <p>Am I missing something or completely misunderstood the entire underlying code for this .NET process?</p>