-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProducerGrain.cs
More file actions
35 lines (28 loc) · 932 Bytes
/
ProducerGrain.cs
File metadata and controls
35 lines (28 loc) · 932 Bytes
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
namespace OrleansMissingEvents
{
using Orleans.Runtime;
using Orleans.Streams;
internal class ProducerGrain : Grain, IProducerGrain
{
private IAsyncStream<int> stream;
public override Task OnActivateAsync(CancellationToken cancellationToken)
{
this.stream = this.GetStreamProvider("TestStream")
.GetStream<int>(StreamId.Create("ns", this.GetPrimaryKey()));
return base.OnActivateAsync(cancellationToken);
}
public async Task WakeUpStream()
{
await this.stream.OnNextAsync(-1); // Wake up the stream.
}
public async Task EmitEventsAsync()
{
Console.WriteLine("Emitting events...");
foreach (var i in Enumerable.Range(1, 10))
{
await this.stream.OnNextAsync(i);
await Task.Delay(50);
}
}
}
}