晕那里所有,我一直在寻找与RX架构的解决方案。我的C#4.0级会调用2个不同的方法,并节省时间,我想这样做并行。有什么办法来运行使用无框架并行2种不同的方法?不仅运行的2种方法的同时,也应该等待其他完成,合并了两个结果。示例如下图所示:
AccountClass AC =新AccountClass();
字符串VAL1 = ac.Method1();
布尔将val2 = ac.Method2();
如何,我可以运行在并行运行这2种方法,并等待对方完成,合并结果一起在认购部分?
解决方案 VAR的结果= Observable.Zip(
Observable.Start(()=> callMethodOne()),
Observable.Start(()=> callMethodTwo()),
(一,二)=>新{一个,两个});
result.Subscribe(X => Console.WriteLine(x)的);
Halo there all, I was looking for a solution with RX framework. My C# 4.0 class is going to call 2 different methods and to save the time, I want to do it in parallel. Is there any way to run 2 different methods in parallel using Reactive Framework ? Not only run those 2 methods parallel, but also one should wait for other to complete and combine the both results. Example as shown below:
AccountClass ac = new AccountClass();
string val1 = ac.Method1();
bool val2 = ac.Method2();
How I can run these 2 methods run in parallel and waits each other to complete and combine the results together in the Subscription part ?
解决方案var result = Observable.Zip(
Observable.Start(() => callMethodOne()),
Observable.Start(() => callMethodTwo()),
(one, two) => new { one, two });
result.Subscribe(x => Console.WriteLine(x));
上一篇:如何在情况下,每个列表视图多textviews的设置适配器?适配器、视图、情况下、如何在
下一篇:通过LocalSocket流从MediaRecorder视频视频、LocalSocket、MediaRecorder