Cancels the current operation.

      Syntax

      public void Cancel()

      Examples

      Shows how to use the Cancel method to cancel the current operation.

      using System;
      using ComponentPro.Net.Mail;
      
      ...
      
      public void DoAbort()
      {
          // Create a new Imap instance. 
          Imap client = new Imap();
      
          // Connect to the IMAP server. 
          client.Connect("myserver");
      
          // Authenticate. 
          client.Authenticate("test", "test");
      
          try 
          {
              // Register an event handler. 
              client.Progress += client_Progress;
      
              client.Select("INBOX");
      
              // Download a message with sequence number #1. 
              client.DownloadMessage(1, "c:\\temp\\my message.eml");
          }
          catch (ImapException exc)
          {
              Console.WriteLine("Exception: " + exc.Message);
          }
      
          // Disconnect. 
          client.Disconnect();
      }
      
      void client_Progress(object sender, ImapProgressEventArgs e)
      {
          // Abort the download operation if the bytes transferred is greater than or equal to 500Kb. 
          if (e.State == ImapTransferState.Downloading && e.BytesTransferred >= 1024 * 500)
          {
              ((Imap)sender).Cancel();
          }
      }

      Framework

      .NET Compact Framework.NET Compact Framework

      Supported version: 2.0, 3.5, and 3.9
      Assembly: ComponentPro.Mail.CF (in ComponentPro.Mail.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.Mail (in ComponentPro.Mail.dll)

      Xamarin AndroidXamarin Android

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

      Xamarin MacXamarin Mac

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

      Xamarin iOSXamarin iOS

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

      See Also