Skip to content

Instantly share code, notes, and snippets.

@gsuttie
Created September 16, 2020 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsuttie/da19b253c079004d5f2d98d836bd93a3 to your computer and use it in GitHub Desktop.
Save gsuttie/da19b253c079004d5f2d98d836bd93a3 to your computer and use it in GitHub Desktop.
PeriodicTask
[FunctionName("O_PeriodicTask")]
public static async Task<int> PeriodicTask([OrchestrationTrigger] IDurableOrchestrationContext ctx, ILogger log)
{
var timesRun = ctx.GetInput<int>();
timesRun++;
if (!ctx.IsReplaying)
log.LogWarning($"Starting the PeriodicTask activity {ctx.InstanceId}, {timesRun}");
await ctx.CallActivityAsync("A_PeriodicActivity", timesRun);
var nextRun = ctx.CurrentUtcDateTime.AddSeconds(30);
await ctx.CreateTimer(nextRun, CancellationToken.None);
ctx.ContinueAsNew(timesRun);
return timesRun;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment