Skip to content

Commit 6540914

Browse files
authored
Updated code snippet to use IAsyncCollector
As part of this PR, I have replaced `ICollector` has been with `IAsyncCollector` **Why I feel this change is important** Whether we like it or not, most of the developers (like me) copy the code snippet directly and then modify it as per scenario. Hence, I feel it is important for docs to reflect the best possible in option in the code sample. I'm on the opinion that providing an `async` option over synchronous should be preferred in the snippet. While there is a mention of `IAsyncCollector` in the documentation, no written docs can take can replace the code snippet. This has motivated me to propose this change.
1 parent 3486e2d commit 6540914

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

articles/azure-functions/functions-bindings-service-bus.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -471,12 +471,12 @@ public static void Run(TimerInfo myTimer, ILogger log, out string outputSbQueue)
471471
Here's C# script code that creates multiple messages:
472472

473473
```cs
474-
public static void Run(TimerInfo myTimer, ILogger log, ICollector<string> outputSbQueue)
474+
public static async Task Run(TimerInfo myTimer, ILogger log, IAsyncCollector<string> outputSbQueue)
475475
{
476476
string message = $"Service Bus queue messages created at: {DateTime.Now}";
477477
log.LogInformation(message);
478-
outputSbQueue.Add("1 " + message);
479-
outputSbQueue.Add("2 " + message);
478+
await outputSbQueue.AddAsync("1 " + message);
479+
await outputSbQueue.AddAsync("2 " + message);
480480
}
481481
```
482482

0 commit comments

Comments
 (0)