Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3439574
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:19:36+00:00 2026-05-18T08:19:36+00:00

The following code -scheduler.vb- simulate a Windows Service Using ASP.NET to Run Scheduled Jobs.

  • 0

The following code -scheduler.vb- simulate a Windows Service Using ASP.NET to Run Scheduled Jobs. More info here: http://beckelman.net/post/2008/09/20/Simulate-a-Windows-Service-Using-ASPNET-to-Run-Scheduled-Jobs.aspx

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.

global.asax

 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

scheduler.vb

 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 < 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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:19:36+00:00Added an answer on May 18, 2026 at 8:19 am

    Looking at the link you provided, it looks like this may be an incorrect conversion from C# to VB. The C# code automatically creates a Callback delegate with RunScheduledTasks as its target to pass to Scheduler.Run.

    I suspect that your VB.Net code is looking at this line:

    Scheduler.Run("test", 1, RunScheduledTasks)
    

    and expects RunScheduledTasks to be a function returning a Callback delegate. Unfortunately, I don’t know VB.Net, so I’m guessing here. Maybe it would work if you added the AddressOf operator (link), like so:

    Scheduler.Run("test", 1, AddressOf RunScheduledTasks)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the following code to run a function in another thread: void
Following code, when compiled and run with g++, prints '1' twice, whereas I expect
I have the following code: public Mainform() { ... // scheduler scheduler.DoWork += new
The following code works great in IE, but not in FF or Safari. I
The following code doesn't compile with gcc, but does with Visual Studio: template <typename
The following code illustrates an object literal being assigned, but with no semicolon afterwards:
The following code should find the appropriate project tag and remove it from the
The following code is in the /Courses/Detail action: [AcceptVerbs(GET)] public ActionResult Detail(int id) {
The following code: template <typename S, typename T> struct foo { void bar(); };
The following code has a simple binding which binds the Text of the TextBlock

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.