public void Check(MailCheckAction action) { BackgroundWorker mailCheckWorker = new BackgroundWorker(); mailCheckWorker.DoWork += new DoWorkEventHandler(mailCheckWorker_DoWork); mailCheckWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(mailCheckWorker_CompletedEvent); mailCheckWorker.RunWorkerAsync(action); }
void getNewMailCount(MailCheckAction action) { gmail.Check(action); }
void finishedCheckingMail(int mailCountResult, MailCheckAction action) { newMailCount = mailCountResult; //check if error if (newMailCount == -1) printError("Error while checking for new mail.", gmail.mailException); else { //perform designated action switch (action) { case MailCheckAction.MailInit: if (newMailCount != -1) { displayNewMailCount(); timerMailCheck.Enabled = true; } break; case MailCheckAction.TimerCheck: if (mailUpdateOnNewMail) displayNewMailCount(); break; case MailCheckAction.ForceOutput: prevNewMailCount = -1; //force the mail count to display even if it's zero displayNewMailCount(); break; } } }