views:

308

answers:

3

Hi there,

Are there any build in UI capabilities when using Windows Workflow..

Lets say I have a workflow that takes an hour to run where different activities are happening all the time. While it's running I want to see what activity is currently active, what activities have already ran etc..

Do I have to code this UI myself or does WF have built in features that graphically show the status etc of the workflow?

A: 

To find out which state a workflow is in, I subscribe to the WorkflowIdled event and do something like this:

           private delegate void UpdateDelegate();
   void workflowRuntime_WorkflowIdled(object sender, WorkflowEventArgs e)
        {
            StateMachineWorkflowInstance stateMachineInstance = new StateMachineWorkflowInstance(MyManager.WorkflowRuntime, MyInstance.Id);
            UpdateDelegate LclUpdateDelgate = delegate()
            {
                // Update the workflow state on the form thread
                if (stateMachineInstance.CurrentState != null)
                    LabelWorkflowState.Text = stateMachineInstance.CurrentStateName;
                else
                    LabelWorkflowState.Text = "";

            };
            this.Invoke(LclUpdateDelgate);
        }
Khadaji
A: 

There is no built in UI.

But you can create one, either by subscribing to events on the WorflowInstance (see other answer), or by using the Tracking Service.

The former is simple to set up for a quick solution but the latter will work with multiple host processes and long running (unloaded) workflow instances.

Richard
A: 

Check out the this code sample over at MSDN:

http://msdn.microsoft.com/en-us/library/ms741706.aspx

MattK