Deprecated Run()? RRS feed

  • Question

  • I'm very beginner on Rx.

    I just follows LeeCampbell's wonderful Rx series

    but most of example were written with old version of Rx.

    I cannot find any good method to use it as replacement of Run() method.

    Run() seems to be blocking call,

    I have no idea for this.

    Can anybody teach me how I can achieve same effect with Run()?





    Thursday, October 6, 2011 8:40 PM


All replies

  • Use ForEach or Do.
    Thursday, October 6, 2011 9:23 PM
  • What I actually want to run is following sample code:

    var stream = Observable.Never<int>();
    var exceptionThrown = false;
            i => Console.WriteLine("This will never run."),
            ex => exceptionThrown = true);

    Run() blocks the code until it gets OnCompleted() from stream.

    The code was for old version?

    I'm looking for an replacement of Run().





    Thursday, October 6, 2011 9:49 PM
  • Hi,

    You should actually use Subscribe instead of Run.  An observable query that uses Run is no longer asynchronous, which could mean that IEnumerable<T> may be more appropriate for your query.

    - Dave

    Friday, October 7, 2011 3:21 AM
  • ForEach is the replacement for .Run.

    If you expect a timeout after 1 minute, than perhaps just doing .ForEach(...) will throw the exception instead of passing it to the second lambda as you've written.

    I would rather implement your test with Assert.Throws(()=> stream.Timeout(...).ForEach(...)) which should take care of raising the exception directly, although I do not know the semantics of Timeout.

    Saturday, October 15, 2011 9:51 PM
  • Sorry,

    The post are showing their age now. I am slowly working my way through these to update the code to the latest version.


    Lee Campbell

    Lee Campbell http://LeeCampbell.blogspot.com
    Friday, October 28, 2011 1:52 PM