public void RefreshAndRestartTimer()
{
lock (_timerLock)
{
DisableButtons();
_thumbForm.Invoke(new Action<bool>(_thumbForm.ShowAppropriateThumb), true);
int currCount = _gmailClient.Emails.Count;
CheckEmailResult currResult = _gmailClient.LastResult;
_gmailClient.CheckEmail();
//if status has changed or the number of emails has changed
if ((currResult != _gmailClient.LastResult) || (currCount != _gmailClient.Emails.Count))
UpdateIcon();
//
if (_gmailClient.Updated && _gmailClient.Emails.Count > 0)
_thumbForm.Invoke(new Action<int>(_thumbForm.UpdatePreviewThumb), 0);
//if we got mail, and it's not the first time
if (_gmailClient.GotMail && (currResult != CheckEmailResult.None))
{
ShowProgress();
NewMailSound();
}
_thumbForm.Invoke(new Action<bool>(_thumbForm.ShowAppropriateThumb), false);
EnableAppropriateButtons();
int interval = _checkInterval;
if (_gmailClient.LastResult == CheckEmailResult.AccountError)
interval = _errorInterval;
else if (_gmailClient.LastResult == CheckEmailResult.NetworkError)
interval = _connRetryInterval;
_timer.Interval = interval;
_timer.Start();
}
}