Skip to content

Commit 2300754

Browse files
authored
Cleaned up the comments a bit
1 parent 34c10eb commit 2300754

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Misc/AsyncBatchSample.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
// To add the async / batch running into your code:
2+
// 1. Add the whole "AsyncBatchUtil" class from this file into your project.
3+
// 2. Create your own batch runner function, similar to the "RunBatch" method below.
4+
// 3. Create an instance of "AsyncBatchUtil" somewhere in your code (it's called "BatchRunner" below), passing in the batch parameters and batch runner from step 2.
5+
// 4. Create your worksheet functions like "SlowFunction" below, which call "BatchRunner.Run(...)" to run async as part of a batch.
6+
17
using System;
28
using System.Collections.Generic;
39
using System.Threading;
@@ -9,12 +15,12 @@
915

1016
namespace GeneralTestsCS
1117
{
12-
13-
public static class AysyncBatchExample
18+
public static class AsyncBatchExample
1419
{
15-
// 1. Create an instance on the AsyncBatchUtil, passing in some parameters and the btah running function.
20+
// Step 3. from the list.
1621
static readonly AsyncBatchUtil BatchRunner = new AsyncBatchUtil(1000, TimeSpan.FromMilliseconds(250), RunBatch);
1722

23+
// Step 2. from the list.
1824
// This function will be called for each batch, on a ThreadPool thread.
1925
// Each AsyncCall contains the function name and arguments passed from the function.
2026
// The List<object> returned by the Task must contain the results, corresponding to the calls list.
@@ -42,21 +48,15 @@ static async Task<List<object>> RunBatch(List<AsyncBatchUtil.AsyncCall> calls)
4248
return results;
4349
}
4450

51+
// Step 4. from the list.
4552
public static object SlowFunction(string code, int value)
4653
{
4754
return BatchRunner.Run("SlowFunction", code, value);
4855
}
4956
}
5057

51-
58+
// Step 1. from the list.
5259
// This is the main helper class for supporting batched async calls
53-
// To use:
54-
// 1. Create an instance of AsyncBatchUtil, passing in a Func<List<AsyncCall>, Task<List<object>>> to run each batch.
55-
// 2. Call from inside a batched function as:
56-
// public static object SlowFunction(string code, int value)
57-
// {
58-
// return BatchRunner.Run("SlowFunction", code, value);
59-
// }
6060
public class AsyncBatchUtil
6161
{
6262
// Represents a single function call in a batch

0 commit comments

Comments
 (0)