Click here to Skip to main content
14,691,602 members
Articles » Platforms, Frameworks & Libraries » Win32/64 SDK & OS » Windows General
Posted 14 May 2007


29 bookmarked

Guadagno Task Scheduler

Rate me:
Please Sign up or sign in to vote.
1.89/5 (10 votes)
17 Oct 2008CPOL
The Guadagno Task Scheduler is a Windows Service application that allows you to create tasks (.NET assemblies) that can be executed at different intervals.



The Guadagno Task Scheduler is a Windows Service application that allows you to create tasks that can be scheduled to run in a variety of different times and patterns. The tasks are .NET v2.0 assemblies that inherit from the ITaskPlugin interface. For more information on the ITaskPlugin interface, please visit the CodeProject article at or the project homepage on SourceForge at This project has been released to the community. Visit the CodePlex project at


The Guadagno Task Scheduler will look for tasks (plug-ins) to execute by searching the directory specified in the PluginPath configuration section (see the Configuration section). If this value is not found, the default directory of Plugins folder beneath the root of the installation will be used.

Folder Structure

Installation directory   Contains the task scheduler and support files.
\Logs   Contains the log files for the task scheduler and plug-ins.
\Plugins   Contains the plug-ins (the default directory that the task scheduler looks in for plug-ins).

Configuration File

The Guadagno Task Scheduler does not use the typical .NET configuration file; the application uses an XML file for configuration that derives from the Guadagno.Utilities.Configuration.ConfigurationBase class. Look for an article on this class in the near future. This class allows for you to dynamically change the configuration or provide different configuration parameters depending on the name of the machine the application is running on.

Configuration File Schema

<application.settings stage="auto">
        <host name="uatMachinename" stage="uat" comment="" />                
        <host name="prodMachinename" stage="prod" comment="" />                
    <stage name="default">
    <!-- Default configuration settings -->
    <stage name="uat">
    <!-- UAT configuration settings -->
    <stage name="prod">
    <!-- Production configuration settings -->

The root element of the configuration file is the <application.settings> element. <application.settings> has 2+ child nodes: <hosts> and <stage>. <application.settings> has an attribute named stage which indicates which stage element to load. The <stage> attribute can contain one of the following values:

<application.settings stage="Value">
auto   A value of auto reads the machine name; that is the service is running on and looks in the <hosts> section for the appropriate stage to load.
stage name   Explicitly loads the stage.

The default stage is always read and used to provide the default values for the properties of the application. After the default section is read, the configuration class will load the configuration based on the stage attribute for the <application.settings> element.

The PluginPath Property

This property is used to instruct the Guadagno Task Scheduler the directory you wish to use. This property overrides the default directory of \Plugins underneath the installation directory.

The log4net Property

This property is used to provide the log4net configuration for the Guadagno Task Scheduler. The basic configuration provides a number of different log4net appenders, rolling file, Telnet, and SMTP.

Creating a Plug-In or Task

Creating a plug-in or task is as easy as implementing the ITaskPlugin interface. This interface is provided in the .NET assembly TaskPluginInterface.dll.

ITaskPlugin Interface

A sample implementation of the ITaskPlugin interface. For a more complete example, please refer to the article: 'A Flexible .NET Plug-in Architecture, by Joseph Guadagno'.

public class PluginShell : ITaskPlugin
    #region ITaskPlugin Members
    #region ITaskPlugin Properties

    public string Name
        get { return "My sample Task"; }

    public string Description
        get { return "My first test plug-in"; }

    public string Extension
        get { return "The extension that this plug-in handles (not implemented)"; }
    public string ExtensionDescription
        get { return "A description of the extension (not implemented)"; }
    public string Version
        get { return ""; }
    public string Author
        get { return "Joseph Guadagno"; }
    public List<ischeduleditem> Schedule
        get { return m_Schedule; }

    #endregion ITaskPlugin Properties

    #region ITaskPlugin Methods

    public ExecuteResult Execute()

            // Setup the Progress Information
            m_Progress.TotalTasks = 1;
            m_Progress.TotalItems = 1;
            m_Progress.CurrentTask = 0;
            m_Progress.CurrentItem = 0;
            m_Cancel = false;
            // If the EventStart event has been subscribed to let's fire it.
            if (EventStart != null)
                EventStart(this, new PluginEventArgs(m_Progress, 
                           "Starting the task.", null));
            // If the EventStart event has been subscribed to let's fire it.
            if (EventEnd != null)
                if (m_Cancel)
                    EventEnd(this, new PluginEventArgs(m_Progress, 
                             "Task execution was cancelled.", null));
                    EventEnd(this, new PluginEventArgs(m_Progress, 
                             "Task execution is complete.", null));
          // Exit 
          if (m_Cancel)
              return ExecuteResult.Cancelled;
              return ExecuteResult.Ok;
      catch (Exception ex)
          if (EventExceptionOccurred != null)
              EventExceptionOccurred(this, new PluginEventArgs(m_Progress, 
                                     "", ex));
          // Exit with an Exception
          return ExecuteResult.Exception;


    public bool Cancel()
        m_Cancel = true;
        return true;
    #endregion ITaskPlugin Methods
    #region ITaskPlugin Events
    public event OnStart EventStart;
    public event OnEnd EventEnd;
    public event OnProcessing EventProcessing;
    public event OnExceptionOccurred EventExceptionOccurred;
    #endregion ITaskPlugin Events

    #region Private Methods
    /// <summary>
    /// Sample subroutine to demonstrate how to execute work.
    /// </summary>
    /// <returns>
    private ExecuteResult DoWork()
        int longLoop = 120;
        // Reset the currentItem counter
        m_Progress.CurrentItem = 0;
        // Set the numbers of items to process
        m_Progress.TotalItems = longLoop;
        for (int x = 1; x < longLoop; x++)
            // Just Sleep for a half of a second
            m_Log.DebugFormat(Properties.Resources.WorkingOn, x);
            // Update the current item
            m_Progress.CurrentItem = x;
            if (EventProcessing != null)
                PluginEventArgs evt = new PluginEventArgs(m_Progress, 
                                          "Working", null);
                EventProcessing(this, evt);
                if (evt.Cancel == true)
                    m_Cancel = true;
        if (m_Cancel)
            return ExecuteResult.Cancelled;
            return ExecuteResult.Ok;
    #endregion Private Methods


The Schedule Property

The schedule for each task is provided by the task itself. Once the Task Scheduler "discovers" a task within its plug-in directory, it will retrieve the schedule by examining the schedule property. The scheduling component uses the .NET scheduled timer library written by Andrew Brummer (see reference below).

The plug-in can "hard code" the schedule, which is not recommended, or load it from a configuration file. To make it easier for placing the schedule in a configuration file, I encapsulated the different schedule types (IScheduledItem) available from the .NET scheduled timer library into an XML file and provided a utility function, TaskPluginInterface.ScheduleConfig.Load(), to parse the configuration.

An example configuration file:

    <ScheduledTime Base="ByMinute" Offset="1,0" />
    <SimpleInterval StartTime="1/7/08" Interval="5" EndTime="1/15/08"/>
    <SimpleInterval StartTime="1/1/08" Interval="15" />
    <SimpleInterval StartTime="1/2/08" Interval="20" Count="5"/>
    <SingleEvent EventTime="1/15/08" />
        <ScheduledTime Base="ByMinute" Offset="15,0" />
        <ScheduledTime Base="ByMinute" Offset="30,0" />
    <BlockWrapper Base="Daily" BeginOffset="6:00 AM" EndOffset="5:00 PM">
        <ScheduledTime Base="ByMinute" Offset="15,0" />

For more details on TaskPluginInterface, please checkout the CodeProject article at or the project page at

Next Steps / Future Features

  • Refresh / reload the plug-ins when there are directory changes
  • Enable the plug-ins to have / use their own log files


Version Date What was done 5/14/07 Created the initial release of the file.



This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Joseph Guadagno
Web Developer
United States United States
I have been in software development for about 15 years or so. I started out with a small book on QuickBASIC, then moved the Visual Basic for DOS, then Visual Basic for Windows, then Visual Basic .NET and eventually Visual C#. When I am not working at my full time job I donate my time to several community efforts like:

Former President of INETA North America, currently Vice President.
President of the Southeast Valley .NET User Group (SEVDNUG) in Chandler, AZ.
Serving on my City's Parks and Recreation board.

I have or have had the following "MVP" awards:

  • Visual Basic MVP in 1996
  • C# MVP since 2009
  • Telerik MVP since 2010

I maintain a Open Source project on CodePlex which wraps the Bing API called BingSharp.

I also help / organize or participate in several community events:

  • Desert Code Camp
  • AZGiveCamp
  • Organizer for the 1st Time MVP event at the MVP Summit
  • MVP 2 MVP Sessions at MVP Summit.
  • Awesome bean pusher at GeekGive at the MVP Summit.

Comments and Discussions

GeneralGuadagno.Utilities.Configuration.ConfigurationBase Pin
woocareer1-Aug-10 22:45
Memberwoocareer1-Aug-10 22:45 
GeneralGPL Task Scheduler Pin
Danilo Corallo17-Oct-08 6:19
MemberDanilo Corallo17-Oct-08 6:19 
GeneralRe: GPL Task Scheduler Pin
Joseph Guadagno17-Oct-08 6:57
MemberJoseph Guadagno17-Oct-08 6:57 
GeneralRe: GPL Task Scheduler Pin
Danilo Corallo17-Oct-08 7:15
MemberDanilo Corallo17-Oct-08 7:15 
GeneralMissing Pin
Madmaximus5-Jun-07 7:13
MemberMadmaximus5-Jun-07 7:13 
GeneralRe: Missing Pin
Joseph Guadagno5-Jun-07 9:42
MemberJoseph Guadagno5-Jun-07 9:42 
GeneralRe: Missing Pin
ESTAN1-Oct-07 2:14
MemberESTAN1-Oct-07 2:14 
GeneralRe: Missing Pin
Dewey26-Feb-08 18:50
MemberDewey26-Feb-08 18:50 
GeneralRe: Missing Pin
Joseph Guadagno17-Oct-08 5:04
MemberJoseph Guadagno17-Oct-08 5:04 
GeneralDo NOT install this this!!!!!!! Pin
rob996624-May-07 17:44
Memberrob996624-May-07 17:44 
GeneralRe: Do NOT install this this!!!!!!! Pin
Joseph Guadagno24-May-07 18:50
MemberJoseph Guadagno24-May-07 18:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.