1

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).

2 Answers2

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");
      }
   }
}
Community
  • 1
  • 1
GregRos
  • 8,667
  • 3
  • 37
  • 63
  • 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