This documentation is archived and is not being maintained.

WorkflowInvoker::Invoke Method (Activity, TimeSpan)

Invokes a workflow synchronously using the specified workflow definition and time-out interval.

Namespace:  System.Activities
Assembly:  System.Activities (in System.Activities.dll)

static IDictionary<String^, Object^>^ Invoke(
	Activity^ workflow, 
	TimeSpan timeout


Type: System.Activities::Activity
The workflow definition of the workflow to invoke.
Type: System::TimeSpan
The interval in which the workflow must complete before it is aborted and a TimeoutException is thrown.

Return Value

Type: System.Collections.Generic::IDictionary<String, Object>
A dictionary of the root activity’s OutArgument and InOutArgument values keyed by argument name that represent the outputs of the workflow.

This method blocks until the workflow has completed, including idle time. All workflow execution is guaranteed to execute on the invoking thread. If the workflow does not complete within the specified time-out interval the workflow is aborted and a TimeoutException is thrown.


The TimeoutException is only thrown if the time-out interval elapses and the workflow becomes idle during execution. A workflow that takes longer than the specified time-out interval to complete completes successfully if the workflow does not become idle.

The following example invokes a workflow that contains two WriteLine activities and a Delay activity configured with a Duration of one minute. This workflow is invoked twice; the first time with a time-out interval of two minutes, and the second time with a time-out interval of 30 seconds. The first workflow completes successfully, but the second one does not and a TimeoutException is thrown.

Activity wf = new Sequence()
    Activities = 
        new WriteLine()
            Text = "Before the 1 minute delay."
        new Delay()
            Duration = TimeSpan.FromMinutes(1)
        new WriteLine()
            Text = "After the 1 minute delay."

// This workflow completes successfully.
WorkflowInvoker.Invoke(wf, TimeSpan.FromMinutes(2));

// This workflow does not complete and a TimeoutException
// is thrown.
    WorkflowInvoker.Invoke(wf, TimeSpan.FromSeconds(30));
catch (TimeoutException ex)

For an example of using Invoke with output arguments, see the overload of Invoke() with the same parameters as this overload without the time-out interval.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.