diff --git a/src/DurableEngine/SharedMemory.cs b/src/DurableEngine/SharedMemory.cs
index 66093d8..20d02a1 100644
--- a/src/DurableEngine/SharedMemory.cs
+++ b/src/DurableEngine/SharedMemory.cs
@@ -65,5 +65,15 @@ public bool YieldToUserCodeThread(WaitHandle completionHandle)
var shouldStop = index == 0;
return shouldStop;
}
+
+ ///
+ /// Blocks user code thread if the orchestrator-invoker thread is currently running.
+ /// This guarantees that the user-code thread and the orchestration-invoker thread run one
+ /// at a time after this point.
+ ///
+ public void GuaranteeUserCodeTurn()
+ {
+ userCodeThreadTurn.WaitOne();
+ }
}
}
\ No newline at end of file
diff --git a/src/DurableEngine/Tasks/DurableTask.cs b/src/DurableEngine/Tasks/DurableTask.cs
index e9b3b0b..d05eadd 100644
--- a/src/DurableEngine/Tasks/DurableTask.cs
+++ b/src/DurableEngine/Tasks/DurableTask.cs
@@ -38,6 +38,10 @@ public DurableTask(SwitchParameter noWait, Hashtable privateData)
/// Function to write an exception to the pipeline.
public void Execute(Action