Question

I have following code where I try to replay sequence; but PostWorkItem always gets null; I don't understand why. Below code give Stack overflow error.

        Task<List<WorkItem>> WorkItems = DbUtil.GetWorkItems(new List<string>() { WorkItemStatus.NEW, WorkItemStatus.PROCESSING });
         Items = WorkItems.Result;

        replay = Observable.Generate(
                Items.GetEnumerator(),
                events => events.MoveNext(),
                events => events,
                events => events.Current,
                events => System.TimeSpan.FromMilliseconds(50),
                    var);

        replay.Subscribe(
            W => 
                PostWorkItem(W)
            );

        //var.AdvanceBy(System.TimeSpan.FromSeconds(1));

        var.Start();
Was it helpful?

Solution

You need to specify the type parameters in Observable.Generate explicitly so that it doesn't get confused with the non-generic IEnumerator. Try replacing your third line of code with:

replay = Observable.Generate<IEnumerator<WorkItem>,WorkItem>(
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top