/// <summary> /// stop service method /// </summary> protected override void OnStop() { try { Timer.Stop(); LogHelper.AddLog("FCC Email Agent Service stopped"); Emails email = new Emails() { FromEmail = ServiceSettings.AgentEmail, Subject = "Service Email Agent has been stopped", ReceiverUserId = UsersHelper.CheckExistsUserByEmail(ServiceSettings.AdminCredentials.UserName), TypeId = 4, Host = Program.Agent.ServiceSettings.SMTPSettings.Server, Port = Program.Agent.ServiceSettings.SMTPSettings.Port, Body = "Service Stopped!", }; EmailHelper.SendMessage(email); } catch (Exception exception) { string innerException = exception.InnerException == null ? "" : exception.InnerException.Message; string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; LogHelper.AddLog("Error in method: " + methodName + "; Exception: " + exception.Message + " Innner Exception: " + innerException); } }