Now I am using something simmilar to this construction
A.Completed += () =>
{ B.Completed += () =>
{ C.Completed += () =>
{
//
}
C();
}
B();
}
A();
And not very happy with it. Is there a better, more cleaner way to do such kind of sequent/concurrent action execution?
I have a look at Rx framework, but it is designed for other tasks and looks like way overkill for my problem.
There is no need to nest setting up the Completed events, unless someone might actually call B or C before A is completed. If you separate it out, here is what it looks like:
A.Completed += () => { B(); };
B.Completed += () => { C(); };
C.Completed += () => { // };
A();
I think removing the nesting actually makes it much cleaner.
Have a look at ReactiveUI. It's based on Rx and will simplify your code a lot. Here is an example: Calling Web Services in Silverlight using ReactiveXaml
You can have a look at TPL. You can write code like in this thread: link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With