public static void MonitorEmail() { EmailMonitor monitor = new EmailMonitor( ConfigurationManager.AppSettings["Address"], ConfigurationManager.AppSettings["Password"], ConfigurationManager.AppSettings["MSGorillaAccount"], ConfigurationManager.AppSettings["MSGorillaAccountPassword"], ConfigurationManager.AppSettings["MonitorEmailGroupAddress"] ); while (true) { try { int count = monitor.ScanAndReport(); Thread.Sleep(60000); } catch (Exception e) { Logger.Error(e.StackTrace); Logger.Error(e.Message); Thread.Sleep(30000); } } }
protected override void OnStop() { try { LogProvider.Log(GetType()).Debug("Stopping service."); if (monitor != null) { monitor.Dispose(); monitor = null; } if (resender != null) { resender.Dispose(); resender = null; } LogProvider.Log(GetType()).Debug("Stopped service."); } catch (Exception e) { LogProvider.Log(GetType()).Warn(e); } LogProvider.Log(GetType()).Info("EmailBounceBack Stopped."); }