Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing a C# Timer for regular events in ASP.NET
    primarykey
    data
    text
    <p>I am working with an ASP site which requires a "reminder" email to be sent out every x, y and z minutes. I have attempted to start a timer upon an event (like a button click or page load) but this proved to be unreliable as the timers would be disposed of when the server performed an automatic backup or when the aspx.cs file was updated.</p> <p>My new idea is to have a timer constantly running (a check is performed on a page load which ensures its running) and, when it elapses, it checks to see if either x, y or z minutes have elapsed. So if y elapses, it needs to send out a "reminder" email and then restart y's timer.</p> <pre><code>void ParentTimer_Elapsed(object sender, ElapsedEventArgs e) { foreach(Timer childTimer in ChildTimerList) { if(childTimer.Enabled == false) // And therefore has elapsed { sendReminderEmail(childTimer); childTimer = checkAndSetCorrectInterval(childTimer); childTimer.AutoReset = false; childTimer.Enabled = true; } } } </code></pre> <p>The list ChildTimerList would obviously contain x, y and z.</p> <p>Can anybody forsee me running into any problems with this, or are there any better ways to approach it? My perfect solution would be a timer running costantly which doesn't need to be started upon an event but I don't think this is possible with ASP.</p> <p>Furthermore, where should I initialise my parent timer and childlist variables? In a class within the App_Code folder or, statically, in a code-behind aspx.cs page?</p> <p>Thanks in advance.</p> <p>EDIT:</p> <p>Yes, I do mean ASP.NET... :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload