Gets the thread id.

      Syntax

      public virtual int ThreadId { get; set; }

      Examples

      FTP Examples

      Shows how to use Upload method to upload files and directories using 3 threads.

      using System;
      using System.Threading;
      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      static void Main()
      {
          // Create a new class instance. 
          Ftp client = new Ftp();
      
          // Connect to the server. 
          client.Connect("server");
      
          // Authenticate. 
          client.Authenticate("user", "pass");
      
          client.CommandResponse += client_ResponseRead;
      
          // You can register the ThreadStateChanged event here or in the client_Progress event handler as shown below. 
          client.ThreadStateChanged += Thread_StateChanged; 
          client.Progress += client_Progress;
      
          // ... 
       
          // Upload files and subdirectories from "c:\my folder" to "/my folder" using 3 threads. This waits untils these threads complete. 
          client.Upload("c:\\my folder", "/my folder", 3, true);
      
          // ... 
       
          client.Disconnect();
      }
      
      static void client_Progress(object sender, FileSystemProgressEventArgs e)
      {
          // You can access the threads used for the multi-thread file operation here. 
          // Uncomment the following code to register the StateChanged event of each thread. 
          //if (e.State == TransferState.DirectoryStructureBuilt) 
          //{ 
          //    for (int i = 0; i < e.TransferStatistics.Threads.Count; i++) 
          //    { 
          //        e.TransferStatistics.Threads[i].StateChanged += Thread_StateChanged; 
          //    } 
          //} 
       
          // When the multi-thread operation completes the status is MultiFileOperationCompleted. 
          if (e.State == TransferState.MultiFileOperationCompleted)
              Console.WriteLine("File transfer completed");
      }
      
      static long _threadsCompleted;
      static void Thread_StateChanged(object sender, TransferThreadStateChangedEventArgs e)
      {
          if (e.State == TransferThreadState.Stopped) // The thread is stopped 
          {
              TransferThreadInfo info = (TransferThreadInfo)sender;
      
              Console.WriteLine(string.Format("Thread ID {0} completed", info.ThreadId));
      
              Interlocked.Increment(ref _threadsCompleted);
              if (Interlocked.Read(ref _threadsCompleted) == 3)
              {
                  Console.WriteLine("Multi-threads file transfer completed");
              }
          }
      }
      
      static void client_ResponseRead(object sender, CommandResponseEventArgs e)
      {
          Ftp client = (Ftp)sender;
      
          if (client.ThreadId >= 0)
              if (e.Command != null)
                  Console.WriteLine("Thread: {0} - CMD>       {1}", client.ThreadId,
                      e.Command);
              else 
                  Console.WriteLine("Thread: {0} - RESPONSE>  {1}", client.ThreadId,
                      e.Response);
      }

      SFTP Examples

      Shows how to use Upload method to upload files and directories using 3 threads.

      using System;
      using System.Threading;
      using ComponentPro.IO;
      using ComponentPro.Net;
      
      ...
      
      static void Main()
      {
          // Create a new class instance. 
          Sftp client = new Sftp();
      
          // Connect to the server. 
          client.Connect("server");
      
          // Authenticate. 
          client.Authenticate("user", "pass");
      
          client.CommandResponse += client_ResponseRead;
      
          // You can register the ThreadStateChanged event here or in the client_Progress event handler as shown below. 
          client.ThreadStateChanged += Thread_StateChanged; 
          client.Progress += client_Progress;
      
          // ... 
       
          // Upload files and subdirectories from "c:\my folder" to "/my folder" using 3 threads. This waits untils these threads complete. 
          client.Upload("c:\\my folder", "/my folder", 3, true);
      
          // ... 
       
          client.Disconnect();
      }
      
      static void client_Progress(object sender, FileSystemProgressEventArgs e)
      {
          // You can access the threads used for the multi-thread file operation here. 
          // Uncomment the following code to register the StateChanged event of each thread. 
          //if (e.State == TransferState.DirectoryStructureBuilt) 
          //{ 
          //    for (int i = 0; i < e.TransferStatistics.Threads.Count; i++) 
          //    { 
          //        e.TransferStatistics.Threads[i].StateChanged += Thread_StateChanged; 
          //    } 
          //} 
       
          // When the multi-thread operation completes the status is MultiFileOperationCompleted. 
          if (e.State == TransferState.MultiFileOperationCompleted)
              Console.WriteLine("File transfer completed");
      }
      
      static long _threadsCompleted;
      static void Thread_StateChanged(object sender, TransferThreadStateChangedEventArgs e)
      {
          if (e.State == TransferThreadState.Stopped) // The thread is stopped 
          {
              TransferThreadInfo info = (TransferThreadInfo)sender;
      
              Console.WriteLine(string.Format("Thread ID {0} completed", info.ThreadId));
      
              Interlocked.Increment(ref _threadsCompleted);
              if (Interlocked.Read(ref _threadsCompleted) == 3)
              {
                  Console.WriteLine("Multi-threads file transfer completed");
              }
          }
      }
      
      static void client_ResponseRead(object sender, CommandResponseEventArgs e)
      {
          Sftp client = (Sftp)sender;
      
          if (client.ThreadId >= 0)
              if (e.Command != null)
                  Console.WriteLine("Thread: {0} - CMD>       {1}", client.ThreadId,
                      e.Command);
              else 
                  Console.WriteLine("Thread: {0} - RESPONSE>  {1}", client.ThreadId,
                      e.Response);
      }

      Framework

      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.FileSystem.CF (in ComponentPro.FileSystem.CF.dll)

      .NET Framework.NET Framework

      Supported version: 2.0, 3.0, 3.5, 4.0, 4.5.x, 4.6.x and later
      Assembly: ComponentPro.FileSystem (in ComponentPro.FileSystem.dll)

      Portable Class Library for Windows Phone 8.1 and Windows 8.1 Store AppsPortable Class Library for Windows Phone 8.1 and Windows 8.1 Store Apps

      Supported version: 4.6.x and later
      Assembly: ComponentPro.FileSystem.WinPcl (in ComponentPro.FileSystem.WinPcl.dll)

      Universal Windows Platform (includes Windows 10 Mobile, Windows 10 Store Apps and Windows 10 IoT)Universal Windows Platform (includes Windows 10 Mobile, Windows 10 Store Apps and Windows 10 IoT)

      Supported version: 4.6.x and later
      Assembly: ComponentPro.FileSystem.Uwp (in ComponentPro.FileSystem.Uwp.dll)

      Xamarin AndroidXamarin Android

      Supported version: 2.3 and later
      Assembly: ComponentPro.FileSystem.Android (in ComponentPro.FileSystem.Android.dll)

      Xamarin MacXamarin Mac

      Supported version: 2.0.x and later
      Assembly: ComponentPro.FileSystem.Mac (in ComponentPro.FileSystem.Mac.dll)

      Xamarin iOSXamarin iOS

      Supported version: 5.1.x and later
      Assembly: ComponentPro.FileSystem.iOS (in ComponentPro.FileSystem.iOS.dll)

      See Also