WorkflowCommitWorkBatchService Class
Allows custom logic for the commitment of work batches.
Assembly: System.Workflow.Runtime (in System.Workflow.Runtime.dll)
When a work batch is committed the runtime calls into the WorkflowCommitWorkBatchService and gives it a delegate to call to do the actual committing of the work batch. The runtime still has the primary responsibility of committing the work batch but allows the WorkflowCommitWorkBatchService to insert itself in the process for customization around the commit process.
This process allows custom error handling logic. If the WorkflowCommitWorkBatchService owns the transaction, which is the case when the Transaction.Current property returns Nothing therefore necessitating the need to create a new ambient transaction, it is allowed to call the delegate more than once, creating a new transaction for each call. The most common case for this for example is to handle intermittent network problems or SQL cluster failovers. If the call to the WorkflowCommitWorkBatchService.CommitWorkBatchCallback throws an exception WorkflowCommitWorkBatchService can catch this exception, start a new transaction and call the delegate again. This gives a level of resilience to workflow instance execution that otherwise would cause workflows to terminate.
The following example demonstrates a class that inherits from WorkflowCommitWorkBatchService.
'Implementation of the abstract WorkflowCommitWorkBatchService class Class DefaultCommitWorkBatchService Inherits WorkflowCommitWorkBatchService Protected Overrides Sub CommitWorkBatch(ByVal commitWorkBatchCallback As CommitWorkBatchCallback) ' Call base implementation Try MyBase.CommitWorkBatch(commitWorkBatchCallback) Catch e As Exception ' Report work batch commit failures Console.WriteLine("Work batch failed: " + e.Message.ToString()) Throw End Try End Sub End Class
System.Workflow.Runtime.Hosting.WorkflowRuntimeService
System.Workflow.Runtime.Hosting.WorkflowCommitWorkBatchService
System.Workflow.Runtime.Hosting.DefaultWorkflowCommitWorkBatchService
System.Workflow.Runtime.Hosting.SharedConnectionWorkflowCommitWorkBatchService
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.