Generate numbers at random time intervals with rx

后端 未结 1 567
忘掉有多难
忘掉有多难 2020-12-04 00:55

How can I generate a list of number with Rx.Net, like 0-100, where each number is generated at a random time?

edit:

seems like this works

           


        
相关标签:
1条回答
  • 2020-12-04 01:28

    There's an operator for that, you can use Generate:

    var source = Observable.Generate(
      0,
      x => x < 100,
      x => x + 1,
      _ => random.Next(0, 3),
      _ => TimeSpan.FromMilliseconds(random.Next(1, 10)* 1000));
    
    source.Subscribe(x => Console.WriteLine(x));
    
    0 讨论(0)
提交回复
热议问题