private void OnPowerModeChanged(object sender, PowerModeChangedEventArgs e) { if (e.Mode == PowerModes.Suspend) { Imap.Stop(); } }
private void Reconnect(bool checkForNewMails = true) { try { Imap.Stop(); Imap.Start(); if (checkForNewMails) { CheckNewMail(); } } catch (Exception ex) { notifyIcon.ShowBalloonTip(500, "Ошибка соединения", ex.Message, ToolTipIcon.Error); } }
private void timer_Tick(object sender, EventArgs e) { if (Util.IsInternetConnected()) { if (Imap.Started()) { UpdateTrayIcon(Imap.GetUnreadCount()); } else { /* attempt to silently reconnect */ Reconnect(false); } } else { /* Stop if not connected to the internet */ Imap.Stop(); } }
private void OnNetworkAvailabilityChanged(object sender, NetworkAvailabilityEventArgs e) { /* Unfortunately this seems unreliable, so whenever network availability changes * we disconnect and let the tick event take care of reconnecting */ Imap.Stop(); }