-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathProgram.cs
37 lines (33 loc) · 1008 Bytes
/
Program.cs
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
using System.Reactive.Linq;
namespace Generation;
class Program
{
static void Main()
{
}
public static void GenerateItems()
{
IObservable<int> src = Observable.Generate(
(Current: 0, Total: 0, Random: new Random()),
state => state.Total <= 10000,
state =>
{
int value = state.Random.Next(1000);
return (value, state.Total + value, state.Random);
},
state => state.Current);
}
public static void GenerateTimedItems()
{
IObservable<int> src = Observable.Generate(
(Current: 0, Total: 0, Random: new Random()),
state => state.Total < 10000,
state =>
{
int value = state.Random.Next(1000);
return (value, state.Total + value, state.Random);
},
state => state.Current,
state => TimeSpan.FromMilliseconds(state.Random.Next(1000)));
}
}