C # view, create, and delete System Task Scheduler

Source: Internet
Author: User
Tags repetition

View All Task Scheduler programs in the system [csharp] TaskSchedulerClass ts = new TaskSchedulerClass (); ts. connect (null, null); ITaskFolder folder = ts. getFolder ("\"); IRegisteredTaskCollection tasks_exists = folder. getTasks (1); for (int I = 1; I <= tasks_exists.Count; I ++) {IRegisteredTask t = tasks_exists [I];} note that the subscript starts from 1. In this way, all scheduled tasks are traversed and their attributes can be viewed in sequence. If you want to create a scheduled task, you can manually create one and use this code to check the attributes of the task scheduler. 1. instantiate object [csharp] // instantiate the task object TaskSchedulerClass scheduler = new TaskSchedulerClass (); scheduler. connect (null, null); // connection Note: Only Connect can be used 2. set basic attribute [csharp] ITaskDefinition task = schedtion. newTask (0); task. registrationInfo. author = "BluceYoung"; // The Creator task. registrationInfo. description = "http://blog.csdn.net/bluceyoung"; // Description 3. set trigger There are many types of triggers, which will be found when you manually create a scheduled task. For example, the most common trigger is time-based, and the trigger every several days or months uses IDailyTrigger, this is used as an example for many websites. Here I will take ITimerTrigger as an example to implement the trigger effect in just a few minutes. [Csharp] ITimeTrigger tt = (ITimeTrigger) task. triggers. create (_ TASK_TRIGGER_TYPE2.TASK_TRIGGER_TIME); tt. repetition. interval = "PT30M"; // cycle time tt. startBoundary = "2013-01-21T14: 27: 25"; // The execution start time Interval attribute is the set cycle time, but it is not the number of milliseconds we are familiar. The value must meet the "PT1H1M" format, that is, it is executed several hours and several minutes. The value corresponds to the "repetition task interval" in the trigger dialog box, for example: the value will be converted to minutes and added to the trigger. Official explanation: The amount of time between each restart of the task. the format for this string is P <days> DT

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.