Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem in scheduler code
    primarykey
    data
    text
    <p>The following code -scheduler.vb- simulate a Windows Service Using ASP.NET to Run Scheduled Jobs. More info here: <a href="http://beckelman.net/post/2008/09/20/Simulate-a-Windows-Service-Using-ASPNET-to-Run-Scheduled-Jobs.aspx" rel="nofollow">http://beckelman.net/post/2008/09/20/Simulate-a-Windows-Service-Using-ASPNET-to-Run-Scheduled-Jobs.aspx</a></p> <p>Howerver when I try to run the class in my global.asax i get the following error (highlighted on RunScheduledTasks): "Expression does not produce a value", why?? Thanks.</p> <p>global.asax</p> <pre><code> Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) Scheduler.Run("test", 1, RunScheduledTasks) End Sub Public Sub RunScheduledTasks() 'Do stuff here end Sub </code></pre> <p>scheduler.vb</p> <pre><code> Public Class Scheduler Private Class CacheItem Public Name As String Public Callback As Callback Public Cache As Cache Public LastRun As DateTime End Class Public Delegate Sub Callback() Private Shared _numberOfMinutes As Integer = 1 Public Shared Sub Run(ByVal name As String, ByVal minutes As Integer, ByVal callbackMethod As Callback) _numberOfMinutes = minutes Dim cache As New CacheItem() cache.Name = name cache.Callback = callbackMethod cache.Cache = HttpRuntime.Cache cache.LastRun = DateTime.Now AddCacheObject(cache) End Sub Private Shared Sub AddCacheObject(ByVal cache_1 As CacheItem) If cache_1.Cache(cache_1.Name) Is Nothing Then cache_1.Cache.Add(cache_1.Name, cache_1, Nothing, DateTime.Now.AddMinutes(_numberOfMinutes), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, _ AddressOf CacheCallback) End If End Sub Private Shared Sub CacheCallback(ByVal key As String, ByVal value As Object, ByVal reason As CacheItemRemovedReason) Dim obj_cache As CacheItem = DirectCast(value, CacheItem) If obj_cache.LastRun &lt; DateTime.Now Then If obj_cache.Callback IsNot Nothing Then obj_cache.Callback.Invoke() End If obj_cache.LastRun = DateTime.Now End If AddCacheObject(obj_cache) End Sub End Class </code></pre>
    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