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: 11.2.0 build 590 for .NET 4.5
Syntax
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use CloseAsync instead.")]
public IAsyncResult BeginClose(
	bool expungeDeleted,
	AsyncCallback callback,
	Object state
)

Parameters

expungeDeleted
Type: SystemBoolean
Indicates if the messages marked as deleted must be expunged.
callback
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
state
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.
Exceptions
ExceptionCondition
MailBeeInvalidStateExceptionThere is already an operation in progress.
Remarks
This method is an asynchronous version of Close(Boolean).
Examples
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)
{
    imp.EndClose();
    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.Connect("mail.company.com");
    imp.Login("jdoe@company.com", "secret");
    imp.SelectFolder("Inbox");

    // 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.
        System.Threading.Thread.Sleep(1);
        Application.DoEvents();
    }

    // Close the connection.
    imp.Disconnect();
}
See Also