Accepted answer

try this:

public static iobservable<list<string>> geturllist(uri url)
    var result = (
        from request in observable.return(
            getwebrequest(url, false))
        from response in observable.fromasyncpattern<webresponse>(
            request.begingetresponse, request.endgetresponse)()
        from item in geturlcollection(response)
        select item
    return result;

my only concern with this whole approach is that your geturlcollection(response) is returning an enumerable. you really should code this to return an observable.


hmmm i think observable.start is your friend here. you have a bunch of code that it looks like you are forcing into observable sequences, when they really don't look like they are.

remember rx is designed to work with sequences of push data. you seem to have a sequence of 1 that happens to be a list. tpl/task/async would be a good fit here.

if you do want to use rx, i would suggest avoiding boucing around between ienumable and iobservable. doing so is a quick way to creating nasty race conditions and confusing the next developer.

public static iobservable<list<string>> geturllist(uri url) 
  return observable.start(()=>
    var request = getwebrequest(url, false);
    return geturlcollection(request);//code change here??

here you can happily be synchronous in your observable.start delegate. this should be a lot easier for the next guy to understand (i.e. this is a single value sequence with the urlcollection as the value).

Related Query

More Query from same tag