I need to run my task every day at 3 pm, but background task builder just take an interval for the task to be repeated. What is the way to achieve that? (Windows 8.1 universal App).
Asked
Active
Viewed 2,048 times
1
-
What kind of environment are you targetting? Your question is too generic. – tinonetic Mar 15 '15 at 00:54
-
Would it be possible to make a separate program to do the background task? Then you can just have the windows task scheduler run your background task when you need it. – Scott Chamberlain Mar 15 '15 at 01:08
-
possible duplicate of [Creating Scheduled Tasks](http://stackoverflow.com/questions/7394806/creating-scheduled-tasks) – GregRos Mar 15 '15 at 01:30
-
Sorry for bad question.I have read that scheduled taks not available in WINRT. – ahmedwahdan Mar 15 '15 at 09:54
2 Answers
0
Look at a scheduling library.
I have used Quartz before with success: http://www.quartz-scheduler.net/
Otherwise, a simpler and easier solution if viable, is to have your process run according to a scheduled time by the operating system. Windows supports and encourages scheduling of tasks.

Michal Ciechan
- 13,492
- 11
- 76
- 118
0
I encourage you to use the regular Windows task scheduler, if that is indeed your environment. I'd tell you how to do this, but it would just be a repeat of a previous answer: Creating Scheduled Tasks
using System; using Microsoft.Win32.TaskScheduler; class Program { static void Main(string[] args) { // Get the service on the local machine using (TaskService ts = new TaskService()) { // Create a new task definition and assign properties TaskDefinition td = ts.NewTask(); td.RegistrationInfo.Description = "Does something"; // Create a trigger that will fire the task at this time every other day td.Triggers.Add(new DailyTrigger { DaysInterval = 2 }); // Create an action that will launch Notepad whenever the trigger fires td.Actions.Add(new ExecAction("notepad.exe", "c:\\test.log", null)); // Register the task in the root folder ts.RootFolder.RegisterTaskDefinition(@"Test", td); // Remove the task we just created ts.RootFolder.DeleteTask("Test"); } } }
-
If this is in fact a duplicate (Windows environment), the question should be flagged instead of copying the answer. – Kevin Brown-Silva Mar 15 '15 at 01:27
-
You're probably right. I thought the question phrasing was different enough to warrant another answer, but on second thought marking it as duplicate would be more helpful. – GregRos Mar 15 '15 at 01:30