相关疑难解决方法(0)

如何将IEnumerable <Task <T >>转换为IObservable <T>

是否有内置的方法将IEnumerable <Task <T >>转换为IObservable <T>.顺序并不重要,只是我得到的东西,但最好是因为它们已经完成.

如果它还不存在,那么实现它的好方法是什么?

.net c# linq .net-4.0 system.reactive

9
推荐指数
1
解决办法
937
查看次数

Convert IEnumerable&lt;Task&lt;T&gt;&gt; to IObservable&lt;T&gt; with exceptions handling

I want to convert IEnumerable<Task<T>> to IObservable<T>. I found solution to this here:

IObservable<T> ToObservable<T>(IEnumerable<Task<T>> source)
{
    return source.Select(t => t.ToObservable()).Merge();
}
Run Code Online (Sandbox Code Playgroud)

It is perfectly ok for usual cases, but I need to handle exceptions, that could raise in that Tasks... So IObservable<T> should not be dead after first exception.

What I read, recommendation for this use case is to use some wrapper, that will carry actual value or error. So my attempt was

IObservable<Either<T, Exception>> ToObservable<T>(IEnumerable<Task<T>> source) …
Run Code Online (Sandbox Code Playgroud)

c# ienumerable task system.reactive

5
推荐指数
1
解决办法
171
查看次数

标签 统计

c# ×2

system.reactive ×2

.net ×1

.net-4.0 ×1

ienumerable ×1

linq ×1

task ×1