Created
September 16, 2020 18:12
-
-
Save gsuttie/da19b253c079004d5f2d98d836bd93a3 to your computer and use it in GitHub Desktop.
PeriodicTask
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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