CSharpFeeds - All your C# feeds in one place.

Sponsors

Monday, July 09, 2007

How to Create a Custom Workflow Runtime Service

by Keyvan Nayyeri via Keyvan Nayyeri on 7/9/2007 3:43:16 PM

As mentioned in the previous post, it's possible to create a custom workflow runtime service in two ways: deriving from a built-in runtime service or create a custom workflow runtime from an upper level by deriving from WorkflowRuntimeService class.

In both cases you need to create a class and inherit it from one of base classes then override some or all of their methods based on your needs.  Apparently developing a runtime service based on WorkflowRuntimeService is harder than other built-in runtime services.

I don't want to bother you with writing a custom tracking service because it's already done on MSDN and is the easiest runtime service to implement so just give an introduction to the task of building a runtime service from WorkflowRuntimeService and leave the implementation to you because it's beyond a blog post and I can't find a good idea to create a runtime service for it, too.

WorkflowRuntimeService has four method that you can override in your custom runtime services:

  • OnStarted: The method that will be called whenever the service is being started.
  • OnStopped: The method that will called whenever the service is being stopped.
  • Start: The method that will be  called for service start logic.
  • Stop: The method that will be called for service stop logic.

Therefore you can build a custom workflow service by deriving from this base class (and other base classes derived from this one) and overriding some or all methods from the base class.

using System;

using System.Collections.Generic;

using System.Text;

using System.Workflow.Runtime;

using System.Workflow.Runtime.Hosting;

 

namespace CustomWorkflowService

{

    public class CustomRuntime : WorkflowRuntimeService

    {

        protected override void OnStarted()

        {

            // OnStarted() Implementation

            base.OnStarted();

        }

 

        protected override void OnStopped()

        {

            // OnStopped() Implementation

            base.OnStopped();

        }

 

        protected override void Start()

        {

            // Start() Implementation

            base.Start();

        }

 

        protected override void Stop()

        {

            // Stop() Implementation

            base.Stop();

        }

    }

}

After implementing your logic in this code, you can add or remove this service from runtime.  In the next upcoming post I discuss about adding or removing a service from runtime.

email it!bookmark it!digg it!

Original Post: How to Create a Custom Workflow Runtime Service

Subscribe

New Feed

Product Spotlight

Recently Updated Sources

Legal Note

The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.

Advertise with us