Windows Workflow Foundation 3


Does WF support transactions?


I need to start several workflows in one transaction. Something like this:
using (TransactionScope scope = new TransactionScope())
{
  Runtime.CreateWorkflow(typeof(MyWorkflow1)).Start();
  Runtime.CreateWorkflow(typeof(MyWorkflow2)).Start();
  Runtime.CreateWorkflow(typeof(MyWorkflow3)).Start();
  scope.Complete();
}
Basically, If something goes wrong inside the scope, I dont want any of these workflows created/running/persisted. Does WF work this way?
 
Your activity needs to support the notion of transactions as well.  As far as I know, the invoke workflow activity does not. 
so, in order for this to work, you would need to write an invokeworkflow activity that instead of directly starting the workflow, added an item to the workbatch.  Then, on commit, you would actually start the workflows.  It is likely a bit more complicated, but yes, I believe it can be done. 
Matt
I don't think you can do anything that direct from the host, but you could probably create a "wrapper" workflow that has a transaction scope. Then add each of your child workflows as activities in that transaction scope.  In order to do this and get designer support, you can mark your child workflows with the Activity Designer attribute like so:
[ActivityDesigner(typeof(SequenceDesigner))]
This allows you to use it as an activity in your parent workflow, but treat it as a workflow when you are editing it. 
Matt  
 
Imagine, that at some point in my state machine workflow, I need to spawn some number of some other workflows. So I don't know exact number of them, workflow type may vary.
For example, you receive an envelope with orders, and you want to create a subworkflow for each order. If operation is successfull, envelope is marked as processed, if something goes wrong, the envelope is sent to other state and no order subworkflow is spawned at all.
Imho that is a typical use of transactions in real life. All or nothing.
anyone from MS?
Your activity needs to support the notion of transactions as well.  As far as I know, the invoke workflow activity does not. 
so, in order for this to work, you would need to write an invokeworkflow activity that instead of directly starting the workflow, added an item to the workbatch.  Then, on commit, you would actually start the workflows.  It is likely a bit more complicated, but yes, I believe it can be done. 
Matt

Related Links

Access to workflow queues from external processes
Persiste in a custom activity
Workflow re-activates on Final State when using OnWorkflowItemChanged Event
Windows WorkFlow Foundation: Cannot add a new state in between two existing states.
Within VS2008, can't drill down into a workflow without checking it out
SQLTrackingService tracks incorrect WorkflowInstanceEvent order?
XAML Workflows, Property Bindings and Conditions sample
Tracking query timeouts
Insert activity during PreFilterProperties
Passing data from Activity to Activity in XAML Workflows
Problem with x:Class and CreateWorkflow
Activity property resets back to default inside while activity
Designer does not maintain scroll position returning back from eventdrivenactivity to root designer surface in WF 3
InvokeWorkflow inside ReceiveActivity does not start async
stop runnign an istance of a work flow
WorkFlow will not start. Stuck on workflowRuntime.CreateWorkflow?

Categories

MSDN
Data Platform Developm...
Internet Explorer Deve...
Machine Translation an...
Smart Device Development
Office Live Development
Open Specifications
Archived Forums M
Visual Studio General ...
MSBuild
AdSDK Integration & Ad...
Application Compatibil...
General Windows Deskto...
Development with the W...
Hardware Development B...
General Office Develop...
SharePoint 2010 - Setu...
SharePoint Legacy Vers...
SharePoint Legacy Vers...
SharePoint Legacy Vers...
Azure Mobile Apps
Azure Batch
Azure Log Analytics
StorSimple
Azure Mobile Engagement
Cognitive Services
Azure Stack
Azure Blockchain
.NET Framework Class L...
Common Language Runtim...
Team Foundation Server...
Team Foundation Server...
The Architect Role
BizTalk Server Adapter...
XML, System.Xml, MSXML...
The Forum of Sho
TPL Dataflow
JScript Native
Scripting
Visual Basic for Appli...
SyncFx - Microsoft Syn...
.NET Compact Framework
SQL Server Analysis Se...
SQL Server Data Access
SQL Server Replication
SQL Server Database En...
Database Design
Standard 2009: Embedde...
Standard 7: Misc
Windows Embedded Compa...
SQL Server 2012 Report...
SQL Server 2012 SQL To...
Windows Forms Sample A...
WebsitePanel - Support
Bing Maps General
Bing Maps REST, SOAP, ...
Bing Maps Web Controls
Project Server General...
Microsoft Unified Comm...
Silverlight Installati...
Report a Silverlight Bug
Performance Profiling ...
MVVM / ViewModel Patte...
Designing with Silverl...
Retired SharePoint Bus...
Axum Incubation Project
Building Development a...
Building Windows Store...
AppFabric Caching
Core Coding Experience...
Direct3D 10
Doloto
HD DVD Interactivity A...
Managed Extensibility ...
Network Quality of Ser...
patterns & practices: ...
Project Codename:  Jasper
Oracle on Azure
POS for .NET
Search Server: Frequen...
Share your How to samp...
SQL Server 2014 Report...
Visual Basic for Appli...
Visual Basic Language
Visual C# Language
Visual C++ 2008 (Pre-r...
Visual C++ MFC and ATL
Visual Studio Async CTP
Visual Studio Gallery ...
WCF Data Services (Pre...
Windows Presentation F...
Windows Workflow Found...
Windows XP Wireless SDK
Windows Phone push not...
XML in Visual Studio 2...
XML in Visual Studio a...
XML in Windows (MSXML ...
XML Paper Specificatio...

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile