Skip to content

Commit 2b384f3

Browse files
benperkggailey777
andauthored
Update articles/azure-functions/functions-dotnet-class-library.md
Co-authored-by: Glenn Gailey <[email protected]>
1 parent 8921ef2 commit 2b384f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

articles/azure-functions/functions-dotnet-class-library.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ namespace ServiceBusCancellationToken
335335
}
336336
}
337337
```
338-
A common pattern for iterating through an array uses the foreach statement. Within the foreach statement, prior to processing the message, check if a cancellation token has been generated. The most common scenario will be that the IsCancellationRequested property is false and, in that case, your coded business logic will execute. In a seldom, but realistic scenario that IsCancellationRequested is true, you will need to take some precautionary actions. For example, writing a log which stores the fact that this happened and perhaps store the portion of the message batch which has not yet been processed. If you do the latter, then your startup code needs to check if there are any message batches which experienced this shutdown procedure. The actual requirement is based on your specific scenario.
338+
As in the previous example, you commonly iterate through an array using a `foreach` loop. Within this loop and before processing the message, you should check the value of `cancellationToken.IsCancellationRequested` to see if cancellation is pending. In the case where `IsCancellationRequested` is `true`, you may need to take some actions to prepare for a graceful shutdown . For example, you might want to log the status of your code before the shutdown or perhaps write to a persisted store the portion of the message batch which hasn't yet been processed. If you write this kind of information to a persisted store, then your startup code needs to check the store for any unprocessed message batches written during shutdown. What your code needs to do during graceful shutdown depends on your specific scenario.
339339
Event Hubs is an other trigger that supports batch processing messages. The following example is a function method definition for an Event Hubs trigger with a cancellation token that accepts an incoming batch as an array of [EventData](/dotnet/api/microsoft.azure.eventhubs.eventdata) objects:
340340

341341
```csharp

0 commit comments

Comments
 (0)