So I didn’t make it into DDD Scotland either, again the competition was fierce! Worried? Me? Not at all! I’ve currently got 3 sessions submitted to DDD South West! MUHAHAHAHAAA! As before I’ve submitted my intro to PRISM and intro to Workflow 4.0, but this time I’ve also added in a new Unity based session. So vote for me! I’ll get into DDD eventually! :D
In other news I’ve got a few talks lined up at the GL.NET and VBUG User Groups. The dates are:
? September GL.NET – Unity & IoC (link and better name to follow)
So what about NxtGenUG Southampton I hear you cry! Well we’ve got a cracking line up coming up over the coming months. Tonight we’ve got Neil Robbins coming down from the big smoke to do his talk on Document Databases.
Then on the 15th April we join in the UK Tech Days launch festivities with our own Richard Costal talking about Silverlight 4, and have a special guest from Microsoft joining us. Details to follow on the special guest!
On the 27th May we have all round Guru Liz Keogh joining us to talk about BDD. This should prove to be an excellent session, because if you have any examples you’d like Liz to apply BDD during the session then submit them to me via email me at JohnMc@NxtGenUG.net and she’ll select the best ones.
Then on 24th June we’ve got Phil Pursglove coming down to discuss Microsoft’s exciting new Velocity technology.
An absolutely cracking line up I’m sure you’re agree! In fact what are you waiting for?! Go register now! :D
… are making the whole Visual Studio 2010 experience so much better. I know there are a whole range of fantastic features coming in Visual Studio 2010 and everyone’s blogging about them. But for me there are a whole host of little ones too that are going into making the next version better.
For instance, we’re all familiar with the Quick Watch and Watch Panes. They’re invaluable when you’re poking around debugging stuff. But something new that has entered VS 2010 is the ability to pin watches onto the code itself. So you can hover over a variable like you always have to see its value
but now you can pin that value in place and add comments, so whenever you debug into that code, your pinned value is displayed
The following is based on Beta 1 of WF 4.0 and as such might change or be missing in futures releases.
In Part 1 of this series of articles on WF 4.0 we started by looking at the new Sequential Workflow Designer, and creating a basic Sequential Workflow that added greeted a User. In this second part we will be looking at the new Flowchart Workflow and its designer.
So whats a Flowchart Workflow?
The Flowchart Workflow is a new hybrid of the Sequential and State Machine Workflows that we are already familiar with from 3.x. Even though WF was designed to be extensible so that people could extend it with their own custom Workflows, Microsoft found that a very large percentage of their customers using WF were bending over backwards to crowbar their Workflows into either the Sequential or State Machine types when neither were appropriate. From this Microsoft identified the need for a hybrid type, and this is the result.
So what do you use it for? This is easier to follow if we define when you'd want to use a Sequential and State Machine Workflow first.
So when do you use a Sequential Workflow?
The Sequential Workflow is ideal when you want to model a process that has a defined start and end points and follows a defined (linear) path through a number of Activities. Here's an example:
As you can see even though we have branches in the Workflow, we always go through the same activities and end at our defined point. The Sequential is ideal for modelling Processes.
So when do you use a State Machine Workflow?
The State Machine Workflow is ideal when you want to model a process that doesn't have a defined path and could be one of many paths that will be taken through the Activities. A State Machine does not necessarily need an End Point. Here's an example we're all familiar with.
The State Machine was for Version Control, and as we all know there is no definite path as to how we perform our check in/check outs. One of the best uses for the State Machine Workflow is for Lifecycles of objects, where we have a defined number of States an object can be, in but the direction of state changes comes from an external source.
What about this new Flowchart Workflow?
So hopefully you've now got some idea as to what the original Workflows could do and where they might be used. We can now take a look at the Flowchart Workflow. One of the biggest differences between 3.x and 4.0 is that there is no longer any restriction on which kind of Workflow an Activity can be used on, so our Flowchart Workflow can use exactly the same activities as we did on the Sequential example.
So first off the designer.
As you can see we have the same features as before from the Sequential designer, but this time we have different rules as to how the Activities interact. First off we no longer get connections for free between activities. This is of course down to the nature of the Workflow type, as the designer can't guess what Activities we want to join together and how. So to join Activities together we select the start Activity and then drag one of the edge connectors to the target Activity's edge connector.
Again Variable and Arguments are used in exactly the same way as we did with the Sequential Designer. The Flowchart Workflow currently comes with 3 extra Items (not Activities) that allow us to add decision logic into the Workflow. The first is the FlowDecision which acts as a simple If statement in the logic.
This is actually a very simple Item to use, again dragging from either the green True connector or red False connector to another Activity will give you the path when either a True or False result comes from the Condition you set. The Condition is something that evaluates and returns a boolean result. So far I've been using things like VariableName.Equals("StringToMatch") for the condition. I suspect that in future releases this may have some sort of Expression Editor to it (but this is just my speculation).
The second new item is the FlowSwitch, and looks very similar to the FlowDecision.
OK, so lets put this altogether. I'm going to create a simple Workflow for Pizza management at User Group talks. It's going to ask us our location, if its the home region of Southampton then it'll tell me I need to order Pizza. If it's not Southampton, I'm doing a WF talk somewhere else so I remind the User Group leader. Then because I could in theory be doing a marathon number of talks in one day, it'll ask if my location has changed and if it has we go back to the beginning, otherwise the flow end.
Using the custom Readline and Writeline Activities that were also used on the Sequential Workflow, this is the result. For details as to how to bind to Variables and create them, see Part 1.
A screen cast with the construction of the Pizza Flowchart, will follow shortly.
In Part 3, we will be looking at creating a custom Activity.
This is the first in a number of articles that look at the new features in the WF 4.0, and as such the features might change or be missing in futures releases.
Windows Workflow Foundation 4.0 (WF), along with .NET 4.0 was announced at PDC 2008 and those present were lucky enough to get their hands on a VPC image. The Beta 1 VS2010 ISO is now available for download, you can get it from HERE.
So what's all the fuss about? Well put simply, WF as we know it has been given a complete overhaul from the ground up! They're rewritten the entire foundation and simplified it no end. WF is now far simpler to use and easier to extend. So in the coming series of articles I'll walk you through the new features showing how they differ to the 3.x version.
We're start off with the new Designers provided with WF 4.0. I can't show you the State Machine Designer, as it has been dropped from the 4.0 release. Instead we’ll be getting the Sequential Designer, and the new Flowchart Designer which is kind of a Sequential/State Machine hybrid.
Workflow Designers
The first thing you notice with the designers is that they are now written in WPF! This gives a whole host of advantages to the Designer experience, first off you get all the standard benefits of a WPF application (zooming, scaling, etc) but more importantly it is far more responsive that the old 3.x designer. This has a knock on effect on how you can use Activities on the designer, but we'll come onto that later. Lets have a look at the Sequential Designer.
The designer hasn't changed much from its transition to 3.x, you still insert activities in a vertical line onto it's surface. But what has changed are the addition of a couple of very small innocuous buttons in the bottom left of the designer called "Arguments" and "Variables".
Arguments are the method into which you pass values from the outside world into the Workflow you'll be executing, or from a Workflow into an Activity. Previously in 3.x to pass Arguments into a Workflow this meant dropping into code and adding a number of Dependency Properties in by hand.
So how do you add Arguments to a Workflow in 4.0? Easy, you click the Arguments button and add each Argument into the dialog that appears.
Give the Argument a name, select a Direction, a Type and if required a Default value. Once complete, you’ve created your first Argument.
As you can see, we have the choice of assigning a direction to the Arguments. This does exactly as you'd expect, so values are either taken In (like passing by reference), In Out (like passing by Value), Out (return a value) or as a Property.
But how do you actually get the Arguments into a Workflow? This hasn't changed at all, you still pass in a Dictionary with string keys for each of the values. The key relates to the name of the Argument it will be assigned to.
The Variables functionality is new in WF 4.0 and designer to solve a problem of complexity from 3.x. In 3.x you would have activities binding to each other, but this could lead to some very odd behaviour if the activities bound to the wrong activity and make things complex as an Activity could bind to another activity from either end of a Workflow.
So what the WF team introduced in 4.0 is the concept of variables within a Workflow. Instead of binding Activities to other Activities we now have a broker in the middle to hold the value. It sounds terrible and a bit like a global variable, but it does work very well and is only scoped to the parent Workflow or child Activity, so it's a lot more like Members in a Class. You could almost go as far to say the Workflow is now stateful, as it contains values that change as it executes.
So what does the Variables dialog look like?
To create a new Variable supply a Name, Type and if needed a default Value.
Ok, so what about when we change the context of the Workflow designer? What happens then? Well in that case the Variables window will show all of the Variables available to the selected Activity from the parent Activity (or Workflow) and above. Here you can see that the child Sequence Activity has 2 Variables available to it. AVariable owned by the parent Sequence Activity and it’s own AScopedVariable.
An important point to note here is the mechanism in which we bind Variables to Activities. Binding is now done via an Expression mechanism, so when you bind you can either bind straight to a Variable or alternatively you can enter a value in the box. So say I want to display "Hello" in the Write Activity instead of creating a variable to hold "Hello" and binding to that, I can put "Hello" with quotes straight into the Text property. This is because the property takes in an expression that can either be an explicit value or some sort of expression that can be a value assignment, or property call.
Create your first Sequential Workflow
The following is a textual version of the screencast.
Ok, so lets build a Sequential Workflow using these new features in a Console Application. This Sequential Workflow is going to greet a person we name. Now I'm going to be using a number of custom activities to perform the work, but I won't be going into how they work as this will be covered in a future article.
The process I'll be following is quite simple, the User will be welcomed and then prompted for their name and a greeting will then be displayed.
The first thing we need to do with our Workflow is to add in the Activities, so I'll add in a single WriteLine Activity that write text out to a Console, a custom ReadLine Activity that reads in from the Console, the Greeting activity. I do this in exactly the same manner as we add Activities currently, by dragging them onto the surface in the order I desire.
Now I'm going to need 1 variable for this activity. To hold the name input by the User. I click on the Variables button and add in 1 variable of type string called Name.
I can now assign the Name variable to the Read Activity I'm using to take in the input from the User. I do this by going to the Properties pane with the focus on the desired Activity and binding it to the relevant Variable.
Now I need to bind the input of the Greetings Activity to the Name Variable, I do this in the same manner as before.
If I now build the solution and run it. I get the following experience.
So lets have a look at the code it generated:
This is another important distinction in WF 4.0, there has been a move away from code (VB or C#) and towards declarative coding using XAML. As a rule, the only time you will ever write VB or C# is when you are writing you're very own custom Activities, the rest of the time you will be generating XAML. (Note :- The line that is cut off is just the path to the XAML file).
In the next article, I'll be looking at the new Flowchart Workflow and Designer.
I'll be doing a Windows Workflow Foundation 4 talk at the GL.NET User Group on the 12th August 2009.
The talk will be covering the Beta 1 release of VS2010 and Windows Workflow Foundation, unless Microsoft releases another Beta/Release Candidate by then ;). I'll be looking at the new features of WF 4.0 like the new Workflow Designers and the WPF based Activity functionality.
If you fancy coming along go here to register and I'll see you there!
Having an MSDN subscription I’ve been lucky enough to get Visual Studio 2010 a couple of days early. I’ve installed it happily on my Vista installation (main dev box) and it runs faster (IMHO) than VS2008 does, so I’m dead chuffed!
I then tried installing it on my Win 7 installation (dev laptop), but the damn things always bombs out with the following dialog when the progress bar completes
on this screen
I’ve tried disabling Anti Virus (AVG), removing the external HD it was running from and running it locally, I’ve tried running it from the local HD in CloneDrive as opposed to from the external HD, I’ve tried removing CloneDrive and I’ve even copied the contents of the ISO to a local folder and run it that way. But still no joy.
I thought I’d be smart and check the event logs, but nope, they just said it had completed successfully :P Oddly enough Professional works...
Ah well, if anyone else has any ideas as to why this might have happened I’m open to suggestions :)
I've now been using Windows 7 Beta since release to MSDN subscribers, and am pretty chuffed with it. The new Taskbar is a joy to use, and the whole thing is very stable :)
I've only one niggle with it and that is that when I'm trying to add 3rd party controls to Visual Studio via the browse assemblies dialog, VS2008 has a think, throws a silent fit and disappears. This doesnt happen when adding references.
Has anyone else had experience of this? I shall do some digging and see if I can isolate it a bit more :)
I've now had Windows 7 on my box since Sunday and although i don't have some of the nicer features coming in the Beta (the improved Taskbar and dockable Apps) I'm enjoying the features I've got to play with.
I've hit a problem with the Virtual Hard Disk mounting, where every time I try mounting a VHD file I get told that no provider is available. Here's a piccy of the image.
I've contacted the Windows 7 team (who are VERY helpful) and have identified that is was a problem with my upgrade from Vista as a driver didn't install properly. I haven't got the solution yet, as I'm currently helping the team understand why the installation didn't work. Once we know why it failed, I'll get the solution and I'll post if here. So if you've upgraded from Vista and VHD mounting isn't working and you're getting the same message as me, stay tuned as the solution will be up soon!
So on Windows 7 I'm running the VPC of the WF 4.0. I've run the first 3 labs so far and it's looking damn good. Labs 1 to 3 are:
1. Your first workflow 2. DB interaction 3. Your first WCF hosted Workflow
The new WPF designer is a lot friendlier to use than the original. I particular like that:
You now longer have to jump to code in order to setup variables in the Workflow
And Arguments :)
You can set variables on the activities (a lot friendlier than continually using the Properties pane)
and of course being a WPF based designer, you can now zoom in :)
I've found a few issues so far which I'm about to email in, but here they are in case you're interested in such things:
1. Error messages for activties aren't modal
2. Doing HOL 3, adding Rule called "If DiscountPoints <>
Misspelt variable in condition
Corrected spelling
Finished setting up rest of rule
Noticed the error provider against the "Condition" stating the "Name 'DiscountPoint' is not declared".
This was odd as I had corrected this on the activity
Clicked the property, click a different property. The incorrect value from condition was then used to update the condition on the activity
Correct in the property, click out and the activity was updated3. No feedback from interaction with bread crumbs on WF designer.
3. I would expect highlighting of the word I'm over, or something to show it can be used.
4. WCFTestClient freezes at approx 50% when adding a service that contains an error
5. Compiler didn't pick up error in Assign activity when a variable that didn't exist was used
Whats next? Well I'll be looking at doing a project and putting the walkthough on this blog and looking at writing a session on WF 4.0. Maybe even a comparison with 3.0/3.5 :) Stay tuned for my further adventures in WF and possibly dates for a WF 4.0 session!
WF 3.0/3.5 has effectively been taken out back and shot, and replaced with alot sexier version. First look makes it look far easier to use and extend, and can be skinned with WPF :)
VS2010 is being converted to a WPF based app (like the Expression tools), and will be taking advantage of a new extensibility model being included in .Net 4.0.