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 754613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:02:02+00:00 2026-05-14T15:02:02+00:00

I want to call a specific function on my C# application at a specific

  • 0

I want to call a specific function on my C# application at a specific time. At first I thought about using a Timer (System.Time.Timer), but that soon became impossible to use. Why?

Simple. The Timer class requires a Interval in milliseconds, but considering that I might want the function to be executed, let’s says in a week that would mean:

  • 7 days = 168 hours;
  • 168 hours = 10,080 minutes;
  • 10,080 minutes = 604,800 seconds;
  • 604,800 seconds = 604,800,000 milliseconds;
  • So the interval would be 604,800,000;

Now let’s remember that the Interval accepted data type is int, and as we know int range goes from -2,147,483,648 to 2,147,483,647.

That makes Timer useless, not in this case, but in the case of more than about 25 days, once we cannot set a Interval bigger that 2,147,483,647 milliseconds.


So I need a solution where I could specify when the function should be called. Something like this:

solution.ExecuteAt = "30-04-2010 15:10:00";
solution.Function = "functionName";
solution.Start();

So when the System Time would reach “30-04-2010 15:10:00” the function would be executed in the application.

How can this problem be solved?


Additional information: What will these functions do?

  • Getting climate information and based on that information:
  • Starting / Shutting down other applications (most of them console based);
  • Sending custom commands to those console applications;
  • Power down, rebooting, sleep, hibernate the computer;
  • And if possible schedule the BIOS to power up the computer;

EDIT:

It would seem that the Interval accepted data type is double, however if you set a value bigger that an int to the Interval, and call Start() it throws a exception [0, Int32.MaxValue].

EDIT 2:

Jørn Schou-Rode suggested using Ncron to handle the scheduling tasks, and at first look this seems a good solution, but I would like to hear about some who has worked with it.

  • 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-14T15:02:03+00:00Added an answer on May 14, 2026 at 3:02 pm

    One approach to task scheduling, simliar to that proposed by klausbyskov, is to built your scheduling service on top of an existing .NET scheduling framework/library. Compared to using the Windows Task Scheduler, this has the advantages of (a) allowing several jobs to be defined in the same project and (b) keeping jobs and scheduling logic “together” – i.e. not relying on server settings prone to get lost in system upgrades/replacements.

    I know of two open-source projects that offer this kind of functionality:

    • “Quartz.NET is a full-featured, open source job scheduling system that can be used from smallest apps to large scale enterprise systems.” I have never actually used this framework myself, but from studying the website, I have the impression of a very solid tool, providing many cool features. The fact that there [quartz-net] tag on Stackoverflow might also indicate that it is actually used in the wild.

    • “NCron is a light-weight library for building and deploying scheduled background jobs on the .NET server platform.” It does not have half as many features as Quartz.NET, and it does not have any tag on Stackoverflow, but the author (yours truly) believes that its low-friction API makes it somewhat easier to get started with.

    Building your scheduling service on top of NCron, you can schedule a CleanupJob for weekly execution using a single line of code:

    service.Weekly().Run<CleanupJob>();
    

    Ok, you will need around three lines of boiler plate code on top of that to actually turn your project into a Windows service, but it sounds more impressive when I claim that it can be done with one line of code 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call a function in my application on a specific time without
I want to call specific php function on server from Android application and also
I want to call a function which is in another php class that I
I want to call a webservice using google closures, via jsonp since i am
i want to call the command prompt command using Process.Start and then using StandardOutput
I want to call a web service that requires an authentication cookie. I have
I want to call a function a number of times providing it with different
I built a windows application in C# that is very size specific. I hard
I'm trying to open a PPTX from a specific folder using a Function within
I want to improve the performance of a specific method inside a larger application.

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.