DCSIMG
Finally - We released the JobObjectWrapper project - public: class Alon : IArchitect, IAzure, ICPP, ISmartHome, IHomeServer

Syndication

Finally - We released the JobObjectWrapper project

A job object allows a group of processes to be managed as a unit. Job objects are namable, securable, sharable objects that control attributes of and assign limits to the processes associated with them. Operations performed on the job object affect all processes associated with the job object.
JobObjectWrapper is a .NET abstraction over the Win32 Job Object. With this library you can create job objects, create and assign a process to the job, control process and job limits, and register for the various process- and job-related notification events.

Most of the code is written in C++/CLI. This is a good example of abstracting Win32 mechanism and bringing to the managed world. You can see the power of C++ combined with the modern features of .Net.

This is a snippet from the Job event handler header file:

 

    /// <summary>
    /// Generic delegate for all Job Events
    /// </summary>
    generic<typename TEventArgs> // where TEventArgs : JobEventArgs ^
    public delegate void jobEventHandler(System::Object ^sender, TEventArgs args);
    

    template<typename TEventArgs>
    ref class EventEntry sealed : IEventEntry
    {
    public:
        event jobEventHandler<TEventArgs ^> ^OnJobEvent;
        virtual void Invoke(JobObject ^job, unsigned int messageSpecificValue);
        virtual void AddDelegate(System::MulticastDelegate ^del);
        virtual void RemoveDelegate(System::MulticastDelegate ^del);
    };

 

The EventEntry ::jobEventHandler is a generic event that takes a C++ template argument. If you dive into the source you will see that I use C++ macros to expand all Job Object events. From C#, all look very simple.

 

What's next?

We need a good client application that shows the power of the Job Object mechanism. The application should:

  1. Be a WPF based
  2. Allow the user to create Jobs.
  3. Enable assigning running processes to jobs
  4. Control the processes, put limits and receive events
  5. Save/Load the setting to a configuration file.
  6. Have a Windows service that watch for new processes and assign them to a job according to the user setting.

If anyone want to contribute to the project, please let me know and I'll add him to the team.

 

Please download the code and try it. I will be more than happy to hear your feedback.

 

 

Published Wednesday, August 29, 2007 2:03 AM by Alon Fliess

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Enter the numbers above: