Last active
August 29, 2015 14:14
-
-
Save acple/191b6a9c182795b63b2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reactive.Linq; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var source = Observable.Return(0) // (int 0)で長さ1 | |
.Do(Console.WriteLine) // 監視用 | |
.Repeat() // 無限リピート | |
.Take(7); // 適当に切る | |
source.Subscribe(); | |
// Subscribeが7回目でちゃんとOnCompletedになってるのに | |
// その後もDoのところでOnNext(0) -> OnCompleted() -> OnNext(0) -> が無限ループして永久ブロック | |
} | |
static void Test1() | |
{ | |
var source = Observable.Range(0, 1) // (int 0)で長さ1 | |
.Do(Console.WriteLine) // 監視用 | |
.Repeat() // 無限リピート | |
.Take(7); // 適当に切る | |
source.Subscribe(); | |
// こっちはちゃんと7回でとまる | |
// この2つはスケジューラの違いでRepeatはImmediate、RangeはCurrentThreadらしいです | |
// https://twitter.com/neuecc/status/559287415324434433 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment