Skip to content

Trying to create overlapping Window #1746

Answered by akarnokd
dotnetdan asked this question in Q&A
Discussion options

You must be logged in to vote

The misunderstanding comes from WriteLine where it is not obvious which source value ended up in which window in your code.

var source = Observable.Range(1, 10);
var counter = new int[1];

source
    .Window(2, 1)
    .Subscribe(w =>
    {
        Console.WriteLine("new window:");
        var id = ++counter[i];
        w.Subscribe(x =>
        {
            Console.Write(id);
            Console.Write(": ");
            Console.WriteLine(x);
        });
    });

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by dotnetdan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants