이것은 저에게 효과적입니다. 처음 타이머가 서버에 GC에 의해 수집되지 않습니다 알고 테스트 : 명심
의 Web.config
<configuration>
<system.net>
<mailSettings>
<smtp>
<network defaultCredentials="false" host="mail.domain.com" password="psw" userName="user"/>
</smtp>
</mailSettings>
</system.net>
Global.asax.cs
public class Global : System.Web.HttpApplication {
Timer cron;
protected void Application_Start(object sender, EventArgs e) {
cron = new Timer(1000 * 60 * 5);
cron.AutoReset = true;
cron.Start();
cron.Elapsed += (s, a) => {
var address = "[email protected]";
var mail = new MailMessage("Test <[email protected]>", address);
mail.Subject = "Test";
mail.Body = "Timer test at " + DateTime.Now.ToLongTimeString();
mail.IsBodyHtml = true;
var smtp = new SmtpClient();
smtp.Send(mail);
};
}
protected void Application_End(object sender, EventArgs e) {
cron.Stop();
}
}
그 이 솔루션뿐만 아니라 다른 (thread loop, cache expiration)은 해커입니다. Windows 작업 스케줄러는 이러한 종류의 작업을 수행하도록 설계되었습니다.
문제를 해결 했습니까? – BrOSs