コード例 #1
0
 public void Add(ScheduledTaskConfig service)
 {
     lock (Tasks)
     {
         Tasks.Add(service);
     }
 }
コード例 #2
0
        /// <summary>
        /// Queries the status and other configuration properties of a Windows ScheduledTask.
        /// </summary>
        /// <param name="taskName">The name of the task as shown in the TaskScheduler Contol Panel applet.</param>
        /// <param name="machineName">The server on which the service is running.</param>
        /// <returns>The service configuration details.</returns>
        public static ScheduledTaskConfig QueryStatus(string taskName, string machineName)
        {
            TaskService ts   = new TaskService(machineName);
            Task        task = ts.FindTask(taskName);

            ScheduledTaskConfig config = new ScheduledTaskConfig();

            config.Name        = taskName;
            config.ServerName  = machineName;
            config.State       = task.State.ToString();
            config.Description = task.Definition.RegistrationInfo.Description;

            return(config);
        }