I am creating long running workflow with will create a Bookmark for the persistance.
When I execute the workflow it is workflow is working like a charm.
Issue is here when I enclose the entire workflow in transaction scope, it is not completing its execution once it hits .waitone()
I don't see the execution.
For sure we need the transaction to be present out the workflow. I checked the DTC setting on the DB its ON. I think issue is with bookmarking in WF 4.0 and transaction on top of it.
How much time is you workflow taking to execute. A TransactionScope has a default timeout of 1 minute, if it takes any longer to execute it will abort. And an ACID transaction that lasts 1 minute is normally way to long, it should not last more than a second or 2 as most transactions place locks on resources like databases.
Another thing is you can't persist a workflow in the middle of a transaction. A transaction is an atomic unit and persisting in the middle would mean you are able to restart in the middle and that would very much break the atomic nature of the transaction.
Why would you need a bookmark within a transaction?
Microsoft confirms that WF 4.0 does not support long running workflows inside transactionscope. (I don't have this documented but we had a call with Microsoft team, they confirmed that its not supported). What could happen if you do this: Workflow pauses or hangs
Its weird that Entire WF 4.0 has issues with transactionscopes(invoked outside workflow project). Even though I say PersistableIdle.unload (which should persist to the database and should unload from the memory) which look likes a simple job. I don't understand why its having issues with transactionscopes.