ImapBeginClose Method |
Note: This API is now obsolete.
Namespace: MailBee.ImapMail
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use CloseAsync instead.")] public IAsyncResult BeginClose( bool expungeDeleted, AsyncCallback callback, Object state )
Exception | Condition |
---|---|
MailBeeInvalidStateException | There is already an operation in progress. |
// 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(); }