taskscheduler.cs

来自「一个可以生成windows定时任务的程序」· CS 代码 · 共 74 行

CS
74
字号
using System;
using System.Collections;
using System.Runtime.InteropServices;
using TaskSchedulerInterop;

namespace TaskScheduler
{
	/// <remarks>
	/// Encapsulates the system task scheduler.
	/// </remarks>
	/// <example>
	/// Example creates a local instance of the Task Scheduler and prints the tasks
	/// <code>
	/// Scheduler sched = new Scheduler();
	/// foreach (Task t in sched.Tasks)
	/// {
	///   Console.WriteLine(t.ToString());
	/// }
	/// </code>
	/// </example>
	public class Scheduler
	{
		/// <summary>
		/// Internal field which holds TaskList instance
		/// </summary>
		private readonly TaskList tasks = null;

		/// <summary>
		/// Creates instance of task scheduler on local machine
		/// </summary>
		public Scheduler()
		{
			tasks = new TaskList();
		}

		/// <summary>
		/// Creates instance of task scheduler on remote machine
		/// </summary>
		/// <param name="computer">Name of remote machine</param>
		public Scheduler(string computer)
		{
			tasks = new TaskList();
			TargetComputer = computer;
		}

		/// <summary>
		/// Gets/sets name of target computer. Null or emptry string specifies local computer.
		/// </summary>
		public string TargetComputer
		{
			get
			{
				return tasks.TargetComputer;
			}
			set
			{
				tasks.TargetComputer = value;
			}
		}

		/// <summary>
		/// Gets collection of system tasks
		/// </summary>
		public TaskList Tasks
		{
			get
			{
				return tasks;
			}
		}

	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?