locked
React into two or more asynchonus event with and then RRS feed

  • Question

  • Hi,

    I do my best to google/bing this, but no luck :(

    How react to 2 or more async event ?

    Something like ForkJoin, but the result is like and then

     

    ForkJoin(()=> process01, process =>process02).Finally(()=>done)


    What i mean with similiar with forkJoin
    ForkJoin(()=> callAsync01, process =>callAsync02).Finally(()=>I have 2 result of async01 and async02, do this and that)

     

    What i mean with and then

    Observable
      .FromEvent<SecretService.xxxCompletedEventArgs>
    (
      e => client.xxxCompleted += e,
      e => client.xxxCompleted -= e
    ).And(Observable
      .FromEvent<SecretService.yyyCompletedEventArgs>
    (
      e => client.yyyCompleted += e,
      e => client.yyyCompleted -= e
      )).Then((x, y) =>
    {
       // do something with x and y, i try this and never executed, dunno why T_T, the pattern looks like what i want/need
     // both x and y is a result of silverlight service event btw


    return true;
    });

     

    So, what mistake i did, i was hoping and then works T_T

    If i use onComplete(toFire) event per each calling service, then there will be no different with event system
    using takeUntil like in drag drop sample is not possible
    using forkJoin also not possible...

     

     

     

     

     

     


    My Brain Speak
    Saturday, May 1, 2010 11:21 AM

Answers

All replies

  • Hi Andrew,

    You need to use Observable.Join to create an observable and then use Subscribe to execute the query plan.  See the following thread for a (previously) working example:

    Join Patterns in Rx
    http://social.msdn.microsoft.com/Forums/en-US/rx/thread/3ca3a0d4-ac61-4325-9fa2-ed622830b518

    - Dave


    http://davesexton.com/blog
    • Proposed as answer by Dave Sexton Saturday, May 1, 2010 12:49 PM
    • Marked as answer by Andrew VDB Saturday, May 1, 2010 12:59 PM
    Saturday, May 1, 2010 12:49 PM
  • Observable.Join(Observable
    .FromEvent<SecretService.xxxCompletedEventArgs>
    (
    e => client.xxxCompleted += e,
    e => client.xxxCompleted -= e
    ).And(Observable
    .FromEvent<SecretService.yyyCompletedEventArgs>
    (
    e => client.yyyCompleted += e,
    e => client.yyyCompleted -= e
    )).Then((x, y) =>
    {
      // do something with x and y

    return true;
    })).Subscribe();

     

    Nice, thanks !

     


    My Brain Speak
    Saturday, May 1, 2010 12:59 PM