What is Windows Service Manager?
It is a CRONTAB Linux like Windows service that allows you to specify applications that must be performed in a very flexible and scheduled way. The intent is to run libraries in .NET in a well-planned target allowing each daily activity in a library to perform this activity as expected.
In the picture above, we have the main components of this system that allow running any component that implements a standard interface,
IService. This interface is based on the main methods of a service:
When starting the service, it reads the service processes that manage and execute the windows according to the schedule set. Each process must implement the interface
IService that will allow the service window to manipulate the process in a manner similar to a service under Windows.
ReadCrontab() is responsible for reading the files to be executed.
Having defined the data source that contains the list of processes that must be run, the service takes care of, every 30 seconds, to check this list to instantiate and run any process that has been specified to run.
If that is the exact moment in which the case was set, then it is read from the assembly, instantiated, and executed, and any parameters passed to it are informed of the scheduling process.
The service records of the process windows, and instantiates and runs - before an object "
Item" is created that will allow the process to update the information recorded by the service windows at runtime - so if for some reason, the process is interrupted in unexpected windows of the service may, next time or is started, collect such information, instantiate and run the process so that it completes its task.
Implementing the IService Interface
The implementation of the interface is extremely simple and allows the service with windows to communicate with the process and vice versa. The process can, for example return any exception that occurs during the execution by setting the value for the property
ItemException. The property "
Success" indicates whether the process was executed without any error - it is based on the value of property "
ItemException" to set this value: if the property is equal to "zero", then the return value is
The code available for download as an example contains two classes:
Address class contains only a statement of methods and
Person class implements a very simple and didactic.
The implementation of person runs a loop which will record the progress of the process from the argument "
Commom.Process.Item" until it is completed.
My English is not so good and so I am not so inspired to explain further but the intention is to implement a solution in .NET that allows to run several processes similar to what is Linux Crontab.
If you wish to contribute in any way, please do so. I would like to improve this code and make it useful for more people.
I would also stress that not all the code available here is my complete authorship - unfortunately I did not find in my files the original articles to give due credit to those who rightly deserve it, but I can guarantee that all code here can be used and adapted as it is all free.
So be free.
This code is a long time work implementation stated when I began using C#. At that time, I didn't know reflection yet. This is the recent version updated on 2009-08-29.