4 min read

Installing WinFX

A successful installation of .NET Framework 2.0 is the first thing we need to use Windows WF. You need to have the latest version, because older ones don’t work with the latest bits. On http://msdn.microsoft.com/winfx/, click Get the Beta. You need at least, the WinFX Runtime Components along with the Visual Studio 2005 Extensions for Windows WF. Of course, for the latest item you must have a running Visual Studio installation (Express editions won’t work). These extensions to the integrated development environment (IDE) are necessary because, although it is possible to create the workflow in code, it makes easier to manage the XML and code-behing files Windows WF uses for its work.Downloading the entire Windows SDK to check other new technologies such asWindows Presentation or CommunicationFoundations is also suggested (formerly known as Avalon and Indigo, respectively).

Why Workflows?

Until now, flowcharts and process schemes were done separately from code, just as a way to organize ideas before writing the actual code. But when the task was finished, the scheme remained just as documentation. Also, the capacity of older computers made impossible to retain all the information of a workflow in memory, and it was difficult totranslate from an easy-readable format for human to machine code.

Windows WF tries to solve all these problems, making workflow technology available to every single programmer that uses the .NET Framework, and thereby making it general enough to be used in different situations. That seems the natural step from the interoperability concepts in the Framework; if it can execute code written in a bunch of languages, then why not have a tool that translates a conceptual idea of how a work is to be done in real, compliable code? Windows WF can be used for document management (for that special task it will be integrated into Office12), business cycles, or page flow (by making use of ASP.NET).

There are lots of reasons as to why a developer would choose writing a workflow instead of writing the code. First of all, for programmers, workflows are easier to understand than code, because workflows provide a visual representation of the process. Consequently, code becomes harder to maintain and adapt to new areas. For example, adding a step in the middle of a scheme because we need to have an additional agreement with the user because of newer laws can be real pain for coders, but an easy step forworkflow users. In addition, Windows WF provides a way to extend existing workflows without need of recompiling, so general frameworks can be developed and then customized to fit in different areas.

Basic Concepts

Layers in Windows WF: The first one is the code that uses the workflow, because a workflow is not an application, but instead a set of actions that is executed asynchronously by the engine provided by Windows WF. That’s the key to being able to use a workflow in such a variety of scenarios.

The interface that allows communication between that engine and the executing process is called the Hosting Layer, which provides some extra services apart from Communication (send an receive events and data from and to the workflow), like Persistence (which allows saving the state of the workflow in a storage media to restore it later) or Tracking (so the actual code running the workflow can log the execution of it).

Finally, we find the Runtime Layer, which actually executes the workflow and manages the core services. One different with the other two layers is that Runtime Layer is not extensible, while more services can be added to the Hosting Service.

Apart from these layers, Windows WF comes with an integrated designer that by default integrates smoothly in Visual Studio 2005, but which can be used outside it, so any developer could add drag-and-drop support to its own application.

Activities and the minimal units in Windows WF: Each activity receives some parameters from the developer, executes it actions, and then the flow is transferred to the next activity. Some examples are Code or IfElse activities. As developers, we can create new activities and use it in our own code or create an ActivityLibrary for selling. We can get new activities at no cost on its official website www.windowsworkflow.net.

There are two main kinds of workflows:

1.       Sequential: Its actions are executed in some predefined order with a beginning and an end. Examples of sequential workflows may include installations.

2.       State machines: These workflows don’t have a path, but it’s represented as a set of states and transitions between states. Examples are a web shop: you may need approval for mailing, the user could pay via credit card or with a cheque, and each user is in one state and may go to any order depending on previous questions.

Subscribe to the weekly Packt Hub newsletter

* indicates required


Please enter your comment!
Please enter your name here