ImapBeginClose Method

Note: This API is now obsolete.

Begins an asynchronous request for closing (unselecting) the currently selected folder and optional removing of messages marked as deleted from this folder.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use CloseAsync instead.")]
public IAsyncResult BeginClose(
	bool expungeDeleted,
	AsyncCallback callback,
	Object state


Type: SystemBoolean
Indicates if the messages marked as deleted must be expunged.
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
Type: SystemObject
An object that contains state information for this request. You can leave it a null reference (Nothing in Visual Basic).

Return Value

Type: IAsyncResult
An IAsyncResult that references the asynchronous unselecting folder and expunging deleted messages process.
MailBeeInvalidStateExceptionThere is already an operation in progress.
This method is an asynchronous version of Close(Boolean).
This WinForms sample demonstrates asynchronous unselecting the Inbox folder and expunging of all deleted messages if any.
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.ImapMail;

// Put the code below inside your class.

Imap imp = null;
bool finished = false;

// A callback function. Since it's called on Imap worker thread,
// it cannot update controls on the form or otherwise access UI.
// The only UI-related action permitted in worker thread is
// displaying a message box (MessageBox.Show).
// Any updates of UI must take place on message loop thread.
// See BeginSearch method example on how to update UI in callbacks.
private void CloseCallback(IAsyncResult result)
    finished = true;

// The actual code.
private void Form1_Load(object sender, System.EventArgs e)
    imp = new Imap();

    // Connect to the server, login and select inbox.
    imp.Login("", "secret");

    // Start async close/expunge operation.
    imp.BeginClose(true, new AsyncCallback(CloseCallback), null);

    // Wait until it's finished.
    while (!finished)
        // Process events on message loop thread.
        // Alternatively, we could set imp.RaiseEventsOnMessageLoop
        // to false and use imp.Wait method to perform waiting.

    // Close the connection.
See Also