Forum Discussion
Durable Functions
I'm pretty new to Durable Functions. I have a question regarding terminating them.
So we have an application that iterates through azure storage blobs. 0-n # of blobs where n is pretty much unbounded.
So The orchestration takes the blobs, iterates and does actions against them. Since I come from java, the way that this was implemented was through each iteration, each blob will return 500 items and it will spin off a java thread to do the work. When it hits the thread cap, it will wait until a thread is freed up to continue doing the work.
The question I have is, when I try to terminate this, I've noticed that it will be terminated, and won't list it as running anymore, but looking at the live logs, the threads are continuing to do their work. When we terminate something, do we need to implement some interface so the threads can be interrupted?
Or am I going about this entirely the wrong way and the threads should be removed in favor of async tasks/fan out.
2 Replies
Try this to in C# to implement cancellation tokens in your activity functions
public async Task MyActivityFunction(CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested) { // Perform work here } }- nghiale-trCopper Contributor
Thanks for the reply. Yes, I think I need to refactor my entire application to use async Tasks, then orchestrate the functions. As the way I'm doing them with Threads doesn't seem to match the way it was intended to be used.