ImapWait Method

Note: This API is now obsolete.

Waits until the currently running (if any) asynchronous method is finished.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.3.0 build 647 for .NET 4.5
[ObsoleteAttribute("This method is obsolete in .NET 4.5+.")]
public void Wait()
This method should only be used in WinForms applications in the scenarios when the application message loop is blocked and events raised by asynchronous methods get no chance to be processed.
Caution note Caution
RaiseEventsViaMessageLoop property must be set to false prior to using this method. This is required in order to switch event marshaling mechanism from sending events to the application message loop to the internal thread-independent event processor.

Usually, when the developer uses asynchronous methods which might raise events, it's not possible to use methods like WaitOne(Int32, Boolean), since they would block the message loop and thus prevent events (which are raised on the message loop thread) from getting processed. Wait method provides an alternative approach which addresses the problem.

Another alternative (in WinForms application) to using Wait method is to never block the application message loop. See BeginExecuteCustomCommand(String, String, AsyncCallback, Object) method for the code example.

Note Note
In many cases, it's easier not to use events at all but derive a new class from Imap class and override corresponding OnEventName method in order to get the developer-supplied code executed. See OnConnected(ConnectedEventArgs) method documentation for more information.
See Also