WaitForTaskCompletion Workflow Activity

There are always two steps involved with Workflow Tasks – define the task and wait for it to be completed. So after the DefineTask Workflow Activity is used to assign a task, we need to wait for the task to be completed. The WaitForTaskCompletion activity is used for the second step.

The WaitForTaskCompletion activity has an InArgument property that accepts the WorkflowTaskData variable we named taskData in the DefineTask step. It also allows specifying a duration of type TimeSpan to wait before timing out via the timeOutDuration InArgument. The cancelled and timedOut properties are Boolean OutArguments that you can use to make a decision based on whether the task was cancelled or if the timeout expired prior to the task being cancelled or completed.  When the workflow executes and reaches the WaitForTaskCompletion activity, the workflow pauses until the task is completed. Under the hood, the Workflow Service saves the current state of the workflow to the database and unloads the in-memory footprint of the workflow definition and classes. In other words, the workflow goes idle, persists, and unloads. 

Below is a table of the DefineTask’s properties. 

Property Name Direction Description
cancelled OutArguments

Use a variable of type Boolean to hold the value. Use to make a decision based on whether the task was cancelled. If the task completes and the value of this property is false then you can assume the task completed successfully.

DisplayName

 

The name to display for the workflow activity within the workflow designer.

taskData InArgument

Accepts a WorkflowTaskData variable that is utilized in the DefineTask workflow activity.

timedOut OutArguments

Use a variable of type Boolean to hold the value.  Property used to evaluate whether the timeout expired prior to the task being cancelled or completed.

timeOutDuration InArgument

Duration of type TimeSpan to wait before timing out the workflow task.

Below is a typical business activity that includes DefineTask and WaitForTaskCompletion workflow activities: