ComponentPro UltimateMail

      CheckForUpdatesCompleted Event

      See AlsoMembers Options: Show AllLanguage Filter: AllSend comments on this topic to ComponentPro
      Occurs when an asynchronous CheckForUpdatesAsync operation completes.

      Syntax

      public event ExtendedAsyncCompletedEventHandler<TResult> CheckForUpdatesCompleted

      Examples

      Shows how to handle Update event and use the CheckForUpdatesAsync asynchronous method to check for updates/notifications from the IMAP server (Task-based asynchronous approach).

      using System;
      using System.ComponentModel;
      using ComponentPro;
      using ComponentPro.Net.Mail;
      
      ...
      
      public async void DoNoopAsync()
      {
          // Create a new instance of the Imap class. 
          Imap client = new Imap();
      
          // Connect to the server. 
          await client.ConnectAsync("myserver");
      
          // Or you can specify the IMAP port with 
          // client.Connect("myserver", 143); 
       
          // Login to the server. 
          await client.AuthenticateAsync("user", "password");
      
          // ... 
       
          // Select the 'INBOX' mailbox. 
          await client.SelectAsync("INBOX");
      
          // Register an event handler. 
          client.Update += client_Update;
      
          while (true)
          {
              // Check for updates in 10 seconds. 
              await client.CheckForUpdatesAsync(10000);
      
              // Check your loop condition. 
              // ... 
          }
      
          // ... 
       
          // Disconnect. 
          client.Disconnect();
      }
      
      void client_Update(object sender, ImapUpdateEventArgs e)
      {
          switch (e.Event)
          {
              case ImapUpdateEvent.MessageCount:
                  Console.WriteLine("New message received.");
                  // You can download the newly received message here. 
                  break;
      
              case ImapUpdateEvent.MessageRemoved:
                  Console.WriteLine("One or more messages removed.");
                  break;
          }
      }

      Shows how to handle Update event and use the CheckForUpdatesAsync asynchronous method to check for updates/notifications from the IMAP server (Event-based asynchronous approach).

      using System;
      using System.ComponentModel;
      using ComponentPro;
      using ComponentPro.Net.Mail;
      
      ...
      
      public void DoNoopAsync()
      {
          // Create a new instance of the Imap class. 
          Imap client = new Imap();
      
          // Connect to the server. 
          client.Connect("myserver");
      
          // Or you can specify the IMAP port with 
          // client.Connect("myserver", 143); 
       
          // Login to the server. 
          client.Authenticate("user", "password");
      
          // ... 
       
          // Select the 'INBOX' mailbox. 
          client.Select("INBOX");
      
          // Register an event handler. 
          client.CheckForUpdatesCompleted += client_CheckForUpdatesCompletedCompleted;
          client.Update += client_Update;
      
          // Check for updates in 10 seconds. 
          client.CheckForUpdatesAsync(10000);
      
          // ... 
       
          // Disconnect. 
          client.Disconnect();
      }
      
      void client_Update(object sender, ImapUpdateEventArgs e)
      {
          switch (e.Event)
          {
              case ImapUpdateEvent.MessageCount:
                  Console.WriteLine("New message received.");
                  // You can download the newly received message here. 
                  break;
      
              case ImapUpdateEvent.MessageRemoved:
                  Console.WriteLine("One or more messages removed.");
                  break;
          }
      }
      
      void client_CheckForUpdatesCompletedCompleted(object sender, ExtendedAsyncCompletedEventArgs<bool> e)
      {
          Imap client = (Imap)sender;
          if (e.Error != null)
              Console.WriteLine("Error: " + e.Error.ToString());
          else 
          {
              // Check for updates again. You might want to check some condition before going into the loop again. 
              client.CheckForUpdatesAsync(10000);
          }
      }

      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