File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -65,5 +65,15 @@ public bool YieldToUserCodeThread(WaitHandle completionHandle)
6565 var shouldStop = index == 0 ;
6666 return shouldStop ;
6767 }
68+
69+ /// <summary>
70+ /// Blocks user code thread if the orchestrator-invoker thread is currently running.
71+ /// This guarantees that the user-code thread and the orchestration-invoker thread run one
72+ /// at a time after this point.
73+ /// </summary>
74+ public void GuaranteeUserCodeTurn ( )
75+ {
76+ userCodeThreadTurn . WaitOne ( ) ;
77+ }
6878 }
6979}
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ internal OrchestrationAction GetOrCreateAction()
4949 /// <param name="writeErr">Function to write an exception to the pipeline.</param>
5050 public void Execute ( Action < object > write , Action < ErrorRecord > writeErr )
5151 {
52+ // Ensure that a DurableTask in the usercode thread
53+ // only executes while the orchestration-invoker thread is blocked.
54+ OrchestrationContext . SharedMemory . GuaranteeUserCodeTurn ( ) ;
55+
5256 DurableTask task = this ;
5357
5458 if ( NoWait )
You can’t perform that action at this time.
0 commit comments