Most applications written with the Mail component will be synchronous. Synchronous method gives you the ease-of-use, but it can only returns the control back to the caller after it has finished, meaning that it blocks the execution of the caller for a period of time. Using synchronous method is recommended when you only need to execute one Mail command at a time.
You might decide that your design requires an asynchronous mailing operation when it is needed to execute IMAP, POP3 or SMTP commands simultaneously. Asynchronous methods provide a great deal of power. Asynchronous method is executed on a thread separate from the calling thread. Such operation is useful when an operation is time consuming and other codes need to execute without waiting for the initial operation to complete. In addition, the user interface will be most responsive when asynchronous methods are used.
The following table helps you to decide whether to use synchronous or asynchronous methods
|Synchronous Methods||Asynchronous Methods|
|Easy to implement.||Slightly more difficult to implement and use than synchronous methods.|
|Results are returned directly from the method call.||Results are returned to a Task (Task-based Asynchronous Pattern) or ExtendedAsyncResult object, or the event handler (Asynchronous XXXCompleted events).|
|Do not require an event to implement.||Can be controlled with a Task or ExtendedAsyncResult object or asynchronous events. In the second option, additional event handler(s) are needed.|
|Block the execution of the caller for a period.||Immediately return control to the caller.|
|Error handling occurs during the method call.||Error is returned in a Task or ExtendedAsyncResult object that references the asynchronous operation.|
An XXXCompleted event is a generic term to describe any event used by the Ultimate Mail for .NET that ends with the word "Completed". These events are reserved to notify the application of a process being completed. In addition, all XXXCompleted events are raised by the completion of a corresponding XXXAsync method. For example, in the Imap class, the ConnectCompleted event is raised by asynchronous the ConnectAsync methods.