WorkflowApplication Class
TOC
Collapse the table of content
Expand the table of content

WorkflowApplication Class

.NET Framework (current version)
 

Provides a host for a single instance of a workflow.

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

System.Object
  System.Activities.Hosting.WorkflowInstance
    System.Activities.WorkflowApplication

public sealed class WorkflowApplication : WorkflowInstance

NameDescription
System_CAPS_pubmethodWorkflowApplication(Activity)

Creates a new instance of the WorkflowApplication class with the specified workflow definition.

System_CAPS_pubmethodWorkflowApplication(Activity, IDictionary<String, Object>)

Creates a new instance of the WorkflowApplication class that uses the specified workflow definition and argument values.

System_CAPS_pubmethodWorkflowApplication(Activity, IDictionary<String, Object>, WorkflowIdentity)

Creates a new instance of the WorkflowApplication class that uses the specified workflow definition and argument values, and definition identity.

System_CAPS_pubmethodWorkflowApplication(Activity, WorkflowIdentity)

Creates a new instance of the WorkflowApplication class with the specified workflow definition and definition identity.

NameDescription
System_CAPS_pubpropertyAborted

Gets or sets the Action<T> that is invoked when the workflow instance is aborted.

System_CAPS_pubpropertyCompleted

Gets or sets the Action<T> that is invoked when the workflow instance completes.

System_CAPS_pubpropertyDefinitionIdentity

Gets or sets the definition identity of WorkflowInstance.(Inherited from WorkflowInstance.)

System_CAPS_pubpropertyExtensions

Gets the collection of extensions for the current workflow instance.

System_CAPS_pubpropertyHostEnvironment

Gets or sets the root environment for the workflow instance’s arguments and variables.(Inherited from WorkflowInstance.)

System_CAPS_pubpropertyId

Gets the 128-bit GUID identifier of the current workflow application instance.(Overrides WorkflowInstance.Id.)

System_CAPS_pubpropertyIdle

Gets or sets the Action<T> that is invoked when the current workflow instance becomes idle.

System_CAPS_pubpropertyInstanceStore

Gets or sets an object that provides access to the persisted state of the current instance of the workflow application.

System_CAPS_pubpropertyOnUnhandledException

Gets or sets the Func<T, TResult> that is invoked when the current workflow instance encounters an unhandled exception.

System_CAPS_pubpropertyPersistableIdle

Gets or sets the T:System.Activities.ActivityFunc that is invoked when the current workflow instance is idle and can be persisted.

System_CAPS_protpropertySupportsInstanceKeys

Gets a value that indicates whether the host supports the association of P:System.Runtime.Persistence.InstanceView.InstanceKeys with a run-time instance.(Inherited from WorkflowInstance.)

System_CAPS_pubpropertySynchronizationContext

Gets or sets the SynchronizationContext used for scheduling the workflow instance.(Inherited from WorkflowInstance.)

System_CAPS_pubpropertyUnloaded

Gets or sets the Action<T> that is invoked when the current workflow unloads.

System_CAPS_pubpropertyWorkflowDefinition

Gets the workflow definition of the workflow instance.(Inherited from WorkflowInstance.)

NameDescription
System_CAPS_pubmethodAbort()

Notifies the workflow runtime that this workflow instance should abort.

System_CAPS_pubmethodAbort(String)

Notifies the workflow runtime that this workflow instance should abort for the specified reason.

System_CAPS_pubmethodAddInitialInstanceValues(IDictionary<XName, Object>)

Specifies instance metadata values that are included with the first persistence of a new instance.

System_CAPS_pubmethodBeginCancel(AsyncCallback, Object)

Cancels a workflow instance asynchronously using the specified AsyncCallback and user-provided state.

System_CAPS_pubmethodBeginCancel(TimeSpan, AsyncCallback, Object)

Cancels a workflow instance asynchronously using the specified time-out interval, AsyncCallback, and user-provided state.

System_CAPS_pubmethodSystem_CAPS_staticBeginCreateDefaultInstanceOwner(InstanceStore, WorkflowIdentity, WorkflowIdentityFilter, AsyncCallback, Object)

Creates a default instance owner asynchronously using the IAsyncResult asynchronous design pattern with specified instance store, definition identity, identity filter, callback and state.

System_CAPS_pubmethodSystem_CAPS_staticBeginCreateDefaultInstanceOwner(InstanceStore, WorkflowIdentity, WorkflowIdentityFilter, TimeSpan, AsyncCallback, Object)

Creates a default instance owner asynchronously using the IAsyncResult asynchronous design pattern with specified instance store, definition identity, identity filter, timeout interval, callback and state.

System_CAPS_pubmethodSystem_CAPS_staticBeginDeleteDefaultInstanceOwner(InstanceStore, AsyncCallback, Object)

Deletes a default instance owner asynchronously using the IAsyncResult asynchronous design pattern with specified instance store, callback, and state.

System_CAPS_pubmethodSystem_CAPS_staticBeginDeleteDefaultInstanceOwner(InstanceStore, TimeSpan, AsyncCallback, Object)

Deletes a default instance owner asynchronously using the IAsyncResult asynchronous design pattern with specified instance store, timeout interval, callback, and state.

System_CAPS_pubmethodSystem_CAPS_staticBeginGetInstance(Guid, InstanceStore, AsyncCallback, Object)

Retrieves an instance owner asynchronously using the IAsyncResult asynchronous design pattern with specified instance identifier, instance store, callback, and state.

System_CAPS_pubmethodSystem_CAPS_staticBeginGetInstance(Guid, InstanceStore, TimeSpan, AsyncCallback, Object)

Retrieves an instance owner asynchronously using the IAsyncResult asynchronous design pattern with specified instance identifier, instance store, timeout interval, callback, and state.

System_CAPS_pubmethodSystem_CAPS_staticBeginGetRunnableInstance(InstanceStore, AsyncCallback, Object)

Retrieves a runnable instance owner asynchronously using the IAsyncResult asynchronous design pattern with specified instance store, callback, and state.

System_CAPS_pubmethodSystem_CAPS_staticBeginGetRunnableInstance(InstanceStore, TimeSpan, AsyncCallback, Object)

Retrieves a runnable instance owner asynchronously using the IAsyncResult asynchronous design pattern with specified instance store, timeout interval, callback, and state.

System_CAPS_pubmethodBeginLoad(Guid, AsyncCallback, Object)

Loads a workflow asynchronously from an instance store using the specified instance identifier, callback method, and user-provided state.

System_CAPS_pubmethodBeginLoad(Guid, TimeSpan, AsyncCallback, Object)

Loads a workflow asynchronously from an instance store using the specified instance identifier, timeout period, callback method, and user-provided state.

System_CAPS_pubmethodBeginLoad(WorkflowApplicationInstance, AsyncCallback, Object)

Loads a workflow asynchronously from an instance store using the IAsyncResult asynchronous design pattern with specified instance, callback and state.

System_CAPS_pubmethodBeginLoad(WorkflowApplicationInstance, DynamicUpdateMap, AsyncCallback, Object)

Loads a workflow asynchronously from an instance store using the IAsyncResult asynchronous design pattern with specified instance, update map, callback and state.

System_CAPS_pubmethodBeginLoad(WorkflowApplicationInstance, DynamicUpdateMap, TimeSpan, AsyncCallback, Object)

Loads a workflow asynchronously from an instance store using the IAsyncResult asynchronous design pattern with specified instance, update map, timeout interval, callback and state.

System_CAPS_pubmethodBeginLoad(WorkflowApplicationInstance, TimeSpan, AsyncCallback, Object)

Loads a workflow asynchronously from an instance store using the IAsyncResult asynchronous design pattern with specified instance, timeout interval, callback and state.

System_CAPS_pubmethodBeginLoadRunnableInstance(AsyncCallback, Object)

Initiates an operation to load a runnable workflow instance from the InstanceStore.

System_CAPS_pubmethodBeginLoadRunnableInstance(TimeSpan, AsyncCallback, Object)

Initiates an operation to load a runnable workflow instance from the InstanceStore using the specified time-out interval.

System_CAPS_pubmethodBeginPersist(AsyncCallback, Object)

Persists a workflow instance to an instance store asynchronously using the specified callback method and user-provided state.

System_CAPS_pubmethodBeginPersist(TimeSpan, AsyncCallback, Object)

Persists a workflow instance to an instance store asynchronously using the specified time-out interval, callback method, and user-provided state.

System_CAPS_pubmethodBeginResumeBookmark(Bookmark, Object, AsyncCallback, Object)

Initiates an operation to resume a bookmark using the specified value, callback method, and state.

System_CAPS_pubmethodBeginResumeBookmark(Bookmark, Object, TimeSpan, AsyncCallback, Object)

Initiates an operation to resume a bookmark using the specified value, time-out interval, callback method, and state.

System_CAPS_pubmethodBeginResumeBookmark(String, Object, AsyncCallback, Object)

Initiates an asynchronous operation to resume the bookmark with the specified name, using the specified value, callback method, and state. The bookmark to be resumed is previously created by an activity within the workflow instance.

System_CAPS_pubmethodBeginResumeBookmark(String, Object, TimeSpan, AsyncCallback, Object)

Initiates an asynchronous operation to resume the bookmark with the specified name, using the specified value, time-out interval, callback method, and state. The bookmark to be resumed is previously created by an activity within the workflow instance.

System_CAPS_pubmethodBeginRun(AsyncCallback, Object)

Starts or resumes a workflow instance asynchronously using the specified callback method and user-provided state.

System_CAPS_pubmethodBeginRun(TimeSpan, AsyncCallback, Object)

Starts or resumes a workflow instance asynchronously using the specified time-out interval, callback method, and user-provided state.

System_CAPS_pubmethodBeginTerminate(Exception, AsyncCallback, Object)

Terminates a workflow instance asynchronously using the specified exception, callback method, and user-provided state.

System_CAPS_pubmethodBeginTerminate(Exception, TimeSpan, AsyncCallback, Object)

Terminates a workflow instance asynchronously using the specified exception, time-out interval, callback method, and user-provided state.

System_CAPS_pubmethodBeginTerminate(String, AsyncCallback, Object)

Terminates a workflow instance asynchronously using the specified error message, callback method, and user-provided state.

System_CAPS_pubmethodBeginTerminate(String, TimeSpan, AsyncCallback, Object)

Terminates a workflow instance asynchronously using the specified error message, time-out interval, callback method, and user-provided state.

System_CAPS_pubmethodBeginUnload(AsyncCallback, Object)

Persists and disposes a workflow instance asynchronously using the specified callback method and user-provided state.

System_CAPS_pubmethodBeginUnload(TimeSpan, AsyncCallback, Object)

Persists and disposes a workflow instance asynchronously using the specified time-out interval, callback method, and user-provided state.

System_CAPS_pubmethodCancel()

Cancels the workflow instance.

System_CAPS_pubmethodCancel(TimeSpan)

Cancels the workflow instance using the specified time-out interval.

System_CAPS_pubmethodSystem_CAPS_staticCreateDefaultInstanceOwner(InstanceStore, WorkflowIdentity, WorkflowIdentityFilter)

Creates a default instance owner for the workflow using specified instance store, definition identity, and identity filter.

System_CAPS_pubmethodSystem_CAPS_staticCreateDefaultInstanceOwner(InstanceStore, WorkflowIdentity, WorkflowIdentityFilter, TimeSpan)

Creates a default instance owner for the workflow using specified instance store, definition identity, and identity filter and timeout interval.

System_CAPS_pubmethodSystem_CAPS_staticDeleteDefaultInstanceOwner(InstanceStore)

Deletes a default instance owner for the workflow with specified instance store.

System_CAPS_pubmethodSystem_CAPS_staticDeleteDefaultInstanceOwner(InstanceStore, TimeSpan)

Deletes a default instance owner for the workflow with specified instance store and timeout interval..

System_CAPS_pubmethodEndCancel(IAsyncResult)

Waits for the pending asynchronous cancel operation to complete.

System_CAPS_pubmethodSystem_CAPS_staticEndCreateDefaultInstanceOwner(IAsyncResult)

Waits for the creation of default instance owner to complete.

System_CAPS_pubmethodSystem_CAPS_staticEndDeleteDefaultInstanceOwner(IAsyncResult)

Waits for the deletion of default instance owner to complete.

System_CAPS_pubmethodSystem_CAPS_staticEndGetInstance(IAsyncResult)

Waits for the instance retrieval to complete.

System_CAPS_pubmethodSystem_CAPS_staticEndGetRunnableInstance(IAsyncResult)

Waits for the asynchronous retrieval of runnable instance operation to complete.

System_CAPS_pubmethodEndLoad(IAsyncResult)

Waits for the pending asynchronous load operation to complete.

System_CAPS_pubmethodEndLoadRunnableInstance(IAsyncResult)

Waits for the asynchronous load runnable instance operation to complete.

System_CAPS_pubmethodEndPersist(IAsyncResult)

Waits for the pending asynchronous persist operation to complete.

System_CAPS_pubmethodEndResumeBookmark(IAsyncResult)

Waits for a bookmark resume operation to complete.

System_CAPS_pubmethodEndRun(IAsyncResult)

Waits for the pending asynchronous run operation to complete.

System_CAPS_pubmethodEndTerminate(IAsyncResult)

Waits for the pending asynchronous terminate operation to complete.

System_CAPS_pubmethodEndUnload(IAsyncResult)

Waits for the pending asynchronous unload operation to complete.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodGetBookmarks()

Returns the collection of bookmarks for the workflow instance.

System_CAPS_pubmethodGetBookmarks(TimeSpan)

Returns the collection of bookmarks for the workflow instance using the specified time-out interval.

System_CAPS_protmethodGetExtension<T>()

Returns an extension of the specified type.(Inherited from WorkflowInstance.)

System_CAPS_protmethodGetExtensions<T>()

Returns all extensions found for the specified type.(Inherited from WorkflowInstance.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetInstance(Guid, InstanceStore)

Retrieves the workflow instance using specified instance identifier and instance store.

System_CAPS_pubmethodSystem_CAPS_staticGetInstance(Guid, InstanceStore, TimeSpan)

Retrieves the workflow instance using specified instance identifier, instance store and timeout interval.

System_CAPS_pubmethodSystem_CAPS_staticGetRunnableInstance(InstanceStore)

Retrieves the runnable instance of the workflow with specified instance store.

System_CAPS_pubmethodSystem_CAPS_staticGetRunnableInstance(InstanceStore, TimeSpan)

Retrieves the runnable instance of the workflow with specified instance store and timeout interval.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodLoad(Guid)

Loads the specified workflow instance into memory from an instance store.

System_CAPS_pubmethodLoad(Guid, TimeSpan)

Loads the specified workflow instance into memory from an instance store using the specified time-out interval.

System_CAPS_pubmethodLoad(WorkflowApplicationInstance)

Loads a workflow instance from an instance store with specified instance.

System_CAPS_pubmethodLoad(WorkflowApplicationInstance, DynamicUpdateMap)

Loads a workflow instance from an instance store with specified instance and update map.

System_CAPS_pubmethodLoad(WorkflowApplicationInstance, DynamicUpdateMap, TimeSpan)

Loads a workflow instance from an instance store with specified instance, update map and timeout interval.

System_CAPS_pubmethodLoad(WorkflowApplicationInstance, TimeSpan)

Loads a workflow instance from an instance store with specified instance and timeout interval.

System_CAPS_pubmethodLoadRunnableInstance()

Loads a runnable workflow instance from the InstanceStore.

System_CAPS_pubmethodLoadRunnableInstance(TimeSpan)

Loads a runnable workflow instance from the InstanceStore using the specified time-out interval.

System_CAPS_protmethodOnBeginAssociateKeys(ICollection<InstanceKey>, AsyncCallback, Object)

Called by the workflow runtime to notify the host that new instance keys should be associated with this instance.(Inherited from WorkflowInstance.)

System_CAPS_protmethodOnBeginPersist(AsyncCallback, Object)

Asynchronous call to ask the host to persist the workflow.(Inherited from WorkflowInstance.)

System_CAPS_protmethodOnBeginResumeBookmark(Bookmark, Object, TimeSpan, AsyncCallback, Object)

Called by the workflow runtime to notify the host that a resume bookmark operation is beginning.(Inherited from WorkflowInstance.)

System_CAPS_protmethodOnDisassociateKeys(ICollection<InstanceKey>)

Called by the workflow runtime to notify the host that a certain set of instance keys should no longer be associated with this instance.(Inherited from WorkflowInstance.)

System_CAPS_protmethodOnEndAssociateKeys(IAsyncResult)

Called by the workflow runtime to notify the host that an associate keys operation is complete.(Inherited from WorkflowInstance.)

System_CAPS_protmethodOnEndPersist(IAsyncResult)

Called by the workflow runtime to notify the host that a persist operation is complete.(Inherited from WorkflowInstance.)

System_CAPS_protmethodOnEndResumeBookmark(IAsyncResult)

Called by the workflow runtime to notify the host that a resume bookmark operation is complete.(Inherited from WorkflowInstance.)

System_CAPS_protmethodOnRequestAbort(Exception)

Called by the workflow runtime to notify the host that an abort operation has been requested for the workflow instance.(Inherited from WorkflowInstance.)

System_CAPS_pubmethodPersist()

Persists a workflow instance to an instance store.

System_CAPS_pubmethodPersist(TimeSpan)

Persists a workflow instance to an instance store using the specified time-out interval.

System_CAPS_pubmethodResumeBookmark(Bookmark, Object)

Initiates an operation to resume the specified bookmark, using the specified value. The bookmark to be resumed is previously created by an activity within the workflow instance.

System_CAPS_pubmethodResumeBookmark(Bookmark, Object, TimeSpan)

Initiates an operation to resume the specified bookmark, using the specified value and time-out interval. The bookmark to be resumed is previously created by an activity within the workflow instance.

System_CAPS_pubmethodResumeBookmark(String, Object)

Initiates an operation to resume the bookmark with the specified name, using the specified value. The bookmark to be resumed is previously created by an activity within the workflow instance.

System_CAPS_pubmethodResumeBookmark(String, Object, TimeSpan)

Initiates an operation to resume the bookmark with the specified name, using the specified value and time-out interval. The bookmark to be resumed is previously created by an activity within the workflow instance.

System_CAPS_pubmethodRun()

Begins or resumes the execution of a workflow instance.

System_CAPS_pubmethodRun(TimeSpan)

Begins or resumes the execution of a workflow instance using the specified time-out interval.

System_CAPS_pubmethodTerminate(Exception)

Terminates a workflow instance using the specified exception.

System_CAPS_pubmethodTerminate(Exception, TimeSpan)

Terminates a workflow instance using the specified exception and time-out interval.

System_CAPS_pubmethodTerminate(String)

Terminates a workflow instance using the specified error message.

System_CAPS_pubmethodTerminate(String, TimeSpan)

Terminates a workflow instance using the specified error message and time-out interval.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubmethodUnload()

Persists and unloads a workflow instance.

System_CAPS_pubmethodUnload(TimeSpan)

Persists and unloads a workflow instance using the specified time-out interval.

The WorkflowApplication class provides a host for a single workflow instance. It is a proxy to the actual workflow instance that is managed by the workflow runtime. Users of WorkflowApplication can instruct the workflow runtime to perform actions on a workflow instance by calling the appropriate methods on a WorkflowApplication object. If a requested action is not valid, an exception is thrown.

Using WorkflowApplication you can perform the following tasks:

  1. Create a new workflow instance, or load a workflow instance from an instance store.

  2. Provide extensions to be used by activities within a workflow instance.

  3. Control the execution of a workflow instance.

  4. Resume a bookmark created by an activity within a workflow instance.

  5. Persist or unload a workflow instance.

  6. Be notified of workflow instance lifecycle events.

The following example hosts a workflow using WorkflowApplication. A WorkflowApplication instance is constructed using the specified workflow definition, the desired workflow lifecycle events are handled, and the workflow is invoked with a call to Run. When the workflow is completed, the following output is displayed to the console.

Starting the workflow. Workflow 593976e8-558d-4989-94d6-50a14b34fd7b Idle. Ending the workflow. Workflow 593976e8-558d-4989-94d6-50a14b34fd7b CompletedWorkflow 593976e8-558d-4989-94d6-50a14b34fd7b Unloaded. 
Activity wf = new Sequence
{
    Activities =
     {
         new WriteLine
         {
             Text = "Starting the workflow."
         },
         new Delay
         {
             Duration = TimeSpan.FromSeconds(5)
         },
         new WriteLine
         {
             Text = "Ending the workflow."
         }
     }
};

// Create a WorkflowApplication instance.
WorkflowApplication wfApp = new WorkflowApplication(wf);

// Subscribe to any desired workflow lifecycle events.
wfApp.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
{
    if (e.CompletionState == ActivityInstanceState.Faulted)
    {
        Console.WriteLine("Workflow {0} Terminated.", e.InstanceId);
        Console.WriteLine("Exception: {0}\n{1}",
            e.TerminationException.GetType().FullName,
            e.TerminationException.Message);
    }
    else if (e.CompletionState == ActivityInstanceState.Canceled)
    {
        Console.WriteLine("Workflow {0} Canceled.", e.InstanceId);
    }
    else
    {
        Console.WriteLine("Workflow {0} Completed.", e.InstanceId);

        // Outputs can be retrieved from the Outputs dictionary,
        // keyed by argument name.
        // Console.WriteLine("The winner is {0}.", e.Outputs["Winner"]);
    }
};

wfApp.Aborted = delegate(WorkflowApplicationAbortedEventArgs e)
{
    // Display the exception that caused the workflow
    // to abort.
    Console.WriteLine("Workflow {0} Aborted.", e.InstanceId);
    Console.WriteLine("Exception: {0}\n{1}",
        e.Reason.GetType().FullName,
        e.Reason.Message);
};

wfApp.Idle = delegate(WorkflowApplicationIdleEventArgs e)
{
    // Perform any processing that should occur
    // when a workflow goes idle. If the workflow can persist,
    // both Idle and PersistableIdle are called in that order.
    Console.WriteLine("Workflow {0} Idle.", e.InstanceId);
};

wfApp.PersistableIdle = delegate(WorkflowApplicationIdleEventArgs e)
{
    // Instruct the runtime to persist and unload the workflow
    return PersistableIdleAction.Unload;
};

wfApp.Unloaded = delegate(WorkflowApplicationEventArgs e)
{
    Console.WriteLine("Workflow {0} Unloaded.", e.InstanceId);
};

wfApp.OnUnhandledException = delegate(WorkflowApplicationUnhandledExceptionEventArgs e)
{
    // Display the unhandled exception.
    Console.WriteLine("OnUnhandledException in Workflow {0}\n{1}",
        e.InstanceId, e.UnhandledException.Message);

    Console.WriteLine("ExceptionSource: {0} - {1}",
        e.ExceptionSource.DisplayName, e.ExceptionSourceInstanceId);

    // Instruct the runtime to terminate the workflow.
    // Other choices are Abort and Cancel
    return UnhandledExceptionAction.Terminate;
};

// Run the workflow.
wfApp.Run();

.NET Framework
Available since 4.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft