Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you have control over the server then I would probably go with the Windows Service (like <a href="https://stackoverflow.com/questions/6430203/parallel-process-to-wake-up-and-send-email-alert-72-hours-before-scheduled-event/6430245#6430245">The Evil Greebo said</a>).</p> <p>But assuming you don't, I would create a class, perhaps similar to the one below, which you can use/inherit from. Instantiate this class during the "Application_start" event in global.asax and save a copy of it in the cache. Put your logic in the "ExecuteProcess" method. Your logic would probably look something like (pseudo code):</p> <pre><code>while(true) check for events that need to have notifications sent send any needed notifications wait x seconds and repeate loop </code></pre> <p>Make sure you have a field in your MSSQL database table for tracking whether a notification has been sent.</p> <p>Basic base class:</p> <pre><code>Imports System.Threading Public MustInherit Class LongRunningProcess Public ReadOnly Property Running() As Boolean Get Return _Running End Get End Property Public ReadOnly Property Success() As Boolean Get Return _Success End Get End Property Public ReadOnly Property Exception() As Exception Get Return _Exception End Get End Property Public ReadOnly Property StartTime() As DateTime Get Return _StartTime End Get End Property Public ReadOnly Property EndTime() As DateTime Get Return _EndTime End Get End Property Public ReadOnly Property Args() As Object Get Return _Args End Get End Property Protected _Running As Boolean = False Protected _Success As Boolean = False Protected _Exception As Exception = Nothing Protected _StartTime As DateTime = DateTime.MinValue Protected _EndTime As DateTime = DateTime.MinValue Protected _Args() As Object = Nothing Protected WithEvents _Thread As Thread Private _locker As New Object() Public Sub Execute(ByVal Arguments As Object) SyncLock (_locker) 'if the process is not running, then...' If Not _Running Then 'Set running to true' _Running = True 'Set start time to now' _StartTime = DateTime.Now 'set arguments' _Args = Arguments 'Prepare to process in a new thread' _Thread = New Thread(New ThreadStart(AddressOf ExecuteProcess)) 'Start the thread' _Thread.Start() End If End SyncLock End Sub Protected MustOverride Sub ExecuteProcess() End Class </code></pre> <p>The Args property gives you access from within "ExecuteProcess" to any arguments/variables you might need.</p>
 

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