The mysteries of software development and networking... RSS 2.0



 Saturday, August 30, 2008

According to Matt Winkle some performance enhancements have been made to the Workflow designer in Visual Studio 2008 SP1. Strangely enough no mention of these improvements is made in the release notes. I wonder if they made it in.

Matt Winkle: "In .NET 3.5 SP1, there are no features introduced, but there have been a number of internal improvements made, including some substantial perf gains in the WF designer (for certain scenarios)."

Saturday, August 30, 2008 8:37:17 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
 Friday, August 29, 2008

Windows Workflow scheduling services manage how workflow instances are scheduled by the workflow runtime engine. Whether they are handled in an asynchronous manner through the DefaultWorkflowSchedulerService, or in a manual, synchronous manner through the ManualWorkflowSchedulerService, these services are an important part of your workflow solution.

The application I'm working on right now uses ManualWorkflowScheduler, so I needed to figure out the exact differences between the two scheduler, luckily MSDN actually offers pretty clear documentation:

Default Workflow Scheduler Service

DefaultWorkflowSchedulerService is used by the workflow runtime engine by default. It creates and manages the threads that run workflow instances in an asynchronous manner on the workflow runtime engine. Workflows that are waiting to run are stored in the internal queue of the DefaultWorkflowSchedulerService . When the DefaultWorkflowSchedulerService wants to start a workflow, a thread is acquired from the .NET Framework thread pool and used to run the workflow. The MaxSimultaneousWorkflows property determines how many simultaneous threads the scheduler service will allow at one time. If the limit is four, for example, the DefaultWorkflowSchedulerService will acquire up to four threads from the .NET Framework thread pool to execute the workflows. If four workflows are already running, additional work items (workflows) are placed in the queue and eventually executed as threads become available. The following figure shows how the DefaultWorkflowSchedulerService executes workflows in an asynchronous manner.

defaultworkflowscheduler

You can set the maximum number of workflow instances that can be active at any one time by passing a parameter to the DefaultWorkflowSchedulerService constructor or by using an application configuration file. Task 1: Configure Runtime Services Using Code shows how to configure the DefaultWorkflowSchedulerService class by using the constructor. Task 2: Configure Runtime Services using App.Config shows the same configuration of the DefaultWorkflowSchedulerService but uses an application configuration file.

Manual Workflow Scheduler Service

The ManualWorkflowSchedulerService provides a threading service that enables the host application that creates a workflow instance to donate the Thread on which the workflow instance is run. Using this threading service, host applications can run a workflow instance on a single Thread (that is, in synchronous mode). This mode blocks the execution of the host application until the workflow instance becomes idle. Subsequently, the workflow instance can only be executed by using the RunWorkflow method of this service.

Alternatively, the workflow can be run on a thread created by a .NET timer by setting the useActiveTimers constructor parameter to true. When this timer expires, the workflow is executed on the timer's thread, rather than the host application's thread. This timer is implemented as a DelayActivity activity.

ManualWorkflowSchedulerService controls the number of threads spawned in an ASP.NET process by reusing the thread that made the ASP.NET Web request to run the workflow instance. This ensures that at any time, the number of active threads in the workflow runtime equals the number of active Web requests in the ASP.NET process.

ManualWorkflowSchedulerService does not automatically run a workflow instance that is in the queue. The host must call RunWorkflow to run a specified workflow.

Friday, August 29, 2008 4:49:56 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF

The workflow designer in VS2008 can sometimes be a little sluggish. I ran across a post on the forum which offers the following advice:

Commonly reported issues

1. Time taken to open a workflow document is long.

2. Opening Activity bind dialog is slow.

Reasons for slow down

The Workflow designer relies on parsing the source code in the current project to provide updated design information in workflow design surface, rules dialog intellisense etc. This is mainly to enable scenarios where picking up changes from the source even before the project has been rebuilt.

Tips to make designer perform better

1. Move all types used in workflows to a different project than where the workflows live.

Move interfaces, event types, custom activities, helper classes to a different project than in which the workflow resides. E.g. in the solution from a customer, there were about 10 project, with 10 workflows each and 10 associated event types. These types are all reparsed to update to build the design time type information every time the user changes workflows in the project. Moving these to a different assembly e.g  just one project with all the types needed for the 10 workflow projects will help improve performance.

2. Reduce the number of workflows in a project.

Each workflow is a type ( directly in c#/vb, and indirectly in xoml case) that needs a design time type to be built by parsing, so if there are 10 workfows in a project, opening any workflow in the project for the first time means parsing all the other workflows as well. Classifying these workflows based on their function and grouping them in 2-3 workflows per project improved performance drastically.

3. Re-Factor large state machine workflows into smaller workflows

One example we found from a customer had 780 states and 1000 activity binds in the same workflow, leading to a InitializeComponent() of about 16000 lines. Factoring this state machine into smaller reusable workflows will making designer performance much better, and reduce a lot of redundant states.

4. Don’t do long running work in activity constructors

Activity constructors are called during design time also, so doing things like connecting to a database etc should never be done in constructors, this can make the designer take too long to open workflow documents using these activities.

Friday, August 29, 2008 4:28:45 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
 Monday, August 11, 2008

Tomorrow night I'll be the guest speaker at the BAND (Bangor Area .NET Developers user group). I'll be talking about Workflow Foundation.

Workflow Foundation (WF) is one of the pilars of .NET 3. If you think WF is an end user tool then you’re wrong. It is a framework targeted at software developers that want to embed workflow into their custom applications. This session will explore the WF basics and focus on implementing State Machine Workflows, how to use the workflow runtime and where Windows Communication Foundation fits in the whole picture.

Sign up here.

Monday, August 11, 2008 5:18:14 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
 Wednesday, April 09, 2008

Background: Assume we have workflow which is hosted as a WCF service. Every workflow instance is identified by the workflow instanceId. When a remote call comes into the workflow runtime the runtime needs to identify which workflow instance the caller wants to communicate with. If no identification is provided the runtime will assume a new workflow instance needs to be created.

Consider the following piece of client side code which calls a workflow service called FirstOperation() which is handled by a ReceiveActivity on the server:

ClientProxy proxy = new ClientProxy();
proxy.Open();
proxy.FirstOperation(); //creates a new workflow
proxy.Close();

Now assume a second call needs to be made and the second call needs to be handled by the same workflow because in this workflow there is second ReceiveActivity waiting for the SecondOperation to be called.
The following piece of code will do just that:

ClientProxy proxy = new ClientProxy();
proxy.Open();
proxy.FirstOperation(); //creates a new workflow
//.. more code, keep the WCF channel open
proxy.SecondOperation();
proxy.Close();

The above code will work because the ReceiveActivity in combination with the WorkflowServiceHost automatically adds information to the WCF context. The instanceId of the workflow has been added to the context. The above code is bad design. The connection to the server is a valuable resource and should be closed as soon as possible. The following code snippet show how the context manager is used to retrieve the context from the call which initiates the workflow and is then reused when a new client proxy is created.

ClientProxy proxy = new ClientProxy();
proxy.Open();
proxy.FirstOperation(); //creates a new workflow
IContextManager manager = proxy.InnerChannel.GetProperty();
IDictionary context = manager.GetContext();
proxy.Close();

//.. more code, the WCF channel is now closed

proxy = new ClientProxy();
IContextManager manager = proxy.InnerChannel.GetProperty();
manager.SetContext(context);
proxy.SecondOperation();
proxy.Close();

The IContextManager has been added in .NET 3.5 to help with correlation. The code needed in .NET 3.0 to achieve the similar functionality is much less elegant.

Note 1: Server side both the ReceiveActivity as well as the SendActivity have a Context property allowing for easy access to the context. A common pattern for implementing a callback is to set the context of the SendActivity to the value of the context of the ReceiveActivity. In the scenario illustrated above the context would consist of just the instanceId. In scenarios where the workflow is using send and receive activities within a parallel activity the context will automatically get extended to include a conversationId, allowing the WorkflowServiceHost to correlate an incoming call to the correct receive activity.

Note 2: If you want manually add the instanceId to a context, have a look at this post by Maurice de Beijer.


Wednesday, April 09, 2008 1:59:06 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
 Monday, April 07, 2008

The Boston Code Camp 9 is over and done with. It was a great two day event and kudos to Chris, Chris and all the presenters that put their time and effort into making this an excellent happening!

Here are the two presentations from the session that I did:

04-06-2008 CC9 - Building a State Machine Workflow.zip (231.61 KB)
04-06-2008 CC9 - Building applications with logic.zip (1.78 MB)
Monday, April 07, 2008 10:20:18 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
Architecture | C# | General | WF
 Wednesday, May 09, 2007

Marcel de Vries has delivered a release version of his project on CodePlex in which he offers a set of Workflow activities you can use to implement service operations using Windows Communication Foundation (WCF).

Go to: http://blogs.infosupport.com/marcelv/archive/2007/05/08/WCF-activities-version-1.0-now-released-at-codeplex.aspx

Wednesday, May 09, 2007 8:12:10 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
 Sunday, April 15, 2007

My Amazon <-> WF integration article is now listed as a download on the official .NET 3.0 web site. Cool!

Go to: http://wf.netfx3.com/files/folders/web_services/default.aspx

Sunday, April 15, 2007 2:19:58 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | WF
 Wednesday, February 14, 2007

Chris Bowen (Microsoft Developer Evangalist for New England) and Bob Familiar will be touring New England with a roadshow about development on the .NET 3.0.

Roadshow Schedule and Registration

Rochester, NY

February 27th, 2007

8:30am-4:00pm

Click Here to Register!

Burlington, VT

March 1st, 2007

8:30am-4:00pm

Click Here to Register!

Portland, ME

March 6th, 2007

8:30am-4:00pm

Click Here to Register!

Manchester, NH

March 8th, 2007

8:30am-4:00pm

Click Here to Register!

Farmington, CT

March 20th, 2007

8:30am-4:00pm

Click Here to Register!

Wednesday, February 14, 2007 8:45:25 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | Vista | WF | WPF
 Wednesday, February 07, 2007

My article on integrating Amazon Mechanical Turk into Windows Workflow Foundation has been placed on the Amazon web services developer connection.

Read it here: http://developer.amazonwebservices.com/connect/entry.jspa?entryID=635&ref=featured

Wednesday, February 07, 2007 1:59:25 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | WF
 Wednesday, January 17, 2007

I'll be doing two sessions at the next meeting of the Maine Developer Network user group.

Go to: http://www.maine-devnet.org/Home/Default.aspx to sign up!

Topic       : Implementing application logic in .NET 2.0
Speaker     : Mark Blomsma
Date        : February 27th, 2007
Time        : 10:00 - 12:00
Location    : TBA
Description : This session will be about implementing business logic in .NET 2.0. We'll look at and discuss various architectural issues and how to implement design patterns to help create a blueprint of our application. We'll look at choosing and implementing an exception handling strategy and we'll look at various ways data can flow through our application. Lastly we'll look the Smart Client Software Factory and the guidance offered by the Microsoft Patterns and Practices Group.

Topic       : Developing Windows Vista Q&A
Speaker     : Mark Blomsma
Date        : February 27th, 2007
Time        : 12:30 - 13:30 (possibly longer)
Location    : TBA
Description : Question and Answers session about various aspects of developing for Windows Vista. Send in any questions you want answered to mark.blomsma@develop-one.com.
Wednesday, January 17, 2007 11:00:11 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | Vista | WF | WPF
 Tuesday, November 14, 2006

I just created a new virtual machine image and installed .NET Framework 3.0 and the Windows Workflow Foundation extension for Visual Studio 2005. Pretty smooth install, the 2.9MB download for the .NET Framework turned out to be just a bootstrapper which in turn downloaded another 30MB. Don't you just love high speed Internet, it only took 25 seconds.

Tuesday, November 14, 2006 5:02:26 PM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
General | WF
 Sunday, September 10, 2006

They're out!

MSDN subscribers can download Windows Vista via http://msdn.microsoft.com/.

If you're running Windows XP and want to try out the .NET Framework 3.0 RC1, then get the bits at http://msdn.microsoft.com/windowsvista/downloads/products/getthebeta/default.aspx

The .NET Framework download is available for everyone. Not just MSDN subscribers.

Sunday, September 10, 2006 11:15:37 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
C# | General | Vista | WF | WPF
 Tuesday, February 28, 2006

There will be a session about Windows Workflow Foundation (WWF) by Marcel de Vries on the upcoming Software Developer Event. Just to get a headstart have a look at this article by Dino Espito: http://msdn.microsoft.com/windowsvista/building/workflow/default.aspx?pull=/library/en-us/dnlong/html/wfgetstart.asp

Tuesday, February 28, 2006 7:32:29 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] -
WF
About
This blog is run by Mark Blomsma.
© Copyright 2008
Develop-One
Sign In
Statistics
Total Posts: 323
This Year: 67
This Month: 0
This Week: 0
Comments: 90
All Content © 2008, Develop-One
DasBlog theme 'Business' created by Christoph De Baene (delarou)