-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (32 loc) · 1.17 KB
/
Copy pathProgram.cs
File metadata and controls
43 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using PlayingWithActors.Contracts;
var builder = Host.CreateDefaultBuilder(args)
.UseOrleansClient(client => client.UseLocalhostClustering())
.ConfigureLogging(logging => logging.AddConsole())
.UseConsoleLifetime();
using var host = builder.Build();
await host.StartAsync();
var client = host.Services.GetRequiredService<IClusterClient>();
Console.WriteLine("Begin...");
var tasks = new List<Task>
{
RunCalculationAsync(Guid.NewGuid(), client),
RunCalculationAsync(Guid.NewGuid(), client),
RunCalculationAsync(Guid.NewGuid(), client)
};
//var sharedGrainId = Guid.NewGuid();
//var tasks = new List<Task>
//{
// RunCalculationAsync(sharedGrainId, client),
// RunCalculationAsync(sharedGrainId, client),
// RunCalculationAsync(sharedGrainId, client)
//};
await Task.WhenAll([.. tasks]);
static async Task RunCalculationAsync(Guid grainId, IClusterClient client)
{
var collatz = client.GetGrain<ICollatzGrain>(grainId);
var result = await collatz.FindLongestSequence(1_000_000, 5_000_000);
Console.WriteLine($"Result is {result} from grain {grainId}");
}