예제 #1
0
        /// <summary>
        /// Creates a new IntervalTask (and doesn't run it - call SetTimerInterval() to start it).
        /// taskAction format: context => { /* do work */ }
        /// If a task has already been created, throws a FieldAccessException.
        /// </summary>
        /// <param name="taskAction">An Action to be run on an interval</param>
        /// <returns>The created IntervalTask. Call SetTimerInterval() on the returned object to start it.</returns>
        public static IntervalTask CreateTask(Action taskAction)
        {
            if (Current != null)
            {
                throw new FieldAccessException("CreateTask requested, but a task already exists.");
            }

            Current = new IntervalTask(taskAction);
            return(Current);
        }
예제 #2
0
		/// <summary>
		/// Creates a new IntervalTask (and doesn't run it - call SetTimerInterval() to start it).
		/// taskAction format: context => { /* do work */ }
		/// If a task has already been created, throws a FieldAccessException.
		/// </summary>
		/// <param name="taskAction">An Action to be run on an interval</param>
		/// <returns>The created IntervalTask. Call SetTimerInterval() on the returned object to start it.</returns>
		public static IntervalTask CreateTask(Action taskAction)
		{
			if (Current != null)
				throw new FieldAccessException("CreateTask requested, but a task already exists.");

			Current = new IntervalTask(taskAction);
			return Current;
		}