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)
65
65
var shouldStop = index == 0 ;
66
66
return shouldStop ;
67
67
}
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
+ }
68
78
}
69
79
}
Original file line number Diff line number Diff line change @@ -49,6 +49,10 @@ internal OrchestrationAction GetOrCreateAction()
49
49
/// <param name="writeErr">Function to write an exception to the pipeline.</param>
50
50
public void Execute ( Action < object > write , Action < ErrorRecord > writeErr )
51
51
{
52
+ // Ensure that a DurableTask in the usercode thread
53
+ // only executes while the orchestration-invoker thread is blocked.
54
+ OrchestrationContext . SharedMemory . GuaranteeUserCodeTurn ( ) ;
55
+
52
56
DurableTask task = this ;
53
57
54
58
if ( NoWait )
You can’t perform that action at this time.
0 commit comments