TryGetProfile Method
Collapse the table of content
Expand the table of content

TrackingService.TryGetProfile Method (Type, TrackingProfile)


Must be overridden in the derived class, and when implemented, retrieves the tracking profile for the specified workflow type if one is available.

Namespace:   System.Workflow.Runtime.Tracking
Assembly:  System.Workflow.Runtime (in System.Workflow.Runtime.dll)

protected internal abstract bool TryGetProfile(
	Type workflowType,
	out TrackingProfile profile


Type: System.Type

The Type of the workflow for which to get the tracking profile.

Type: System.Workflow.Runtime.Tracking.TrackingProfile

When this method returns, contains the TrackingProfile to load. This parameter is passed uninitialized.

Return Value

Type: System.Boolean

true if a TrackingProfile for the specified workflow Type is available; otherwise, false. If true, the TrackingProfile is returned in profile.

A tracking service is responsible for managing the tracking profiles available for specific workflow types and specific workflow instances. You can implement this management in whatever manner you choose. For example, you can return the same TrackingProfile for every workflow Type and workflow instance; or you can manage a sophisticated store of tracking profiles referenced by workflow instance, workflow Type, and Version.

The following example demonstrates an implementation of the TryGetProfile method, which calls a private GetProfile method. This example is from the Termination Tracking Service SDK sample. For more information, see.29b7c0d7-cece-4bb9-96d0-c5b6c6e14439

class OrderServiceImpl : IOrderService
    string orderId;
    public WorkflowInstance instanceId;

    // Called by the workflow to pass an order id
    public void CreateOrder(string Id)
        Console.WriteLine("\nPurchase Order Created in System");
        orderId = Id;

    // Called by the host to approve an order
    public void ApproveOrder()
        EventHandler<OrderEventArgs> orderApproved = this.OrderApproved;
        if (orderApproved != null)
            orderApproved(null, new OrderEventArgs(instanceId.InstanceId, orderId));

    // Called by the host to reject an order
    public void RejectOrder()
        EventHandler<OrderEventArgs> orderRejected = this.OrderRejected;
        if (orderRejected != null)
            orderRejected(null, new OrderEventArgs(instanceId.InstanceId, orderId));

    // Events that handled within a workflow by HandleExternalEventActivity activities
    public event EventHandler<OrderEventArgs> OrderApproved;
    public event EventHandler<OrderEventArgs> OrderRejected;

.NET Framework
Available since 3.0
Return to top
© 2015 Microsoft